package com.ruoyi.web.controller.system;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.temporal.WeekFields;
import java.util.*;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.SysBudgetYouyong;
import com.ruoyi.system.domain.SysYyZhouhui;
import com.ruoyi.system.domain.vo.*;
import com.ruoyi.system.service.ISysBudgetYouyongService;
import com.ruoyi.system.service.ISysYyZhouhuiService;
import org.aspectj.weaver.loadtime.Aj;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysYyZhouhuiFixed;
import com.ruoyi.system.service.ISysYyZhouhuiFixedService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * SysYyZhouhuiFixedController
 * 
 * @author SYF
 * @date 2025-06-10
 */
@RestController
@RequestMapping("/system/weeklydashboard")
public class SysYyZhouhuiFixedController extends BaseController {

    @Autowired
    private ISysYyZhouhuiFixedService sysYyZhouhuiFixedService;

    @Autowired
    private ISysBudgetYouyongService budgetYouyongService;

    @Autowired
    private ISysYyZhouhuiService ysYyZhouhuiService;

    @GetMapping("/listDsInitDictData")
    public AjaxResult listDsInitDictData(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        Date today = new Date();
        String year = sdf.format(today);
        String sql = "select distinct `year` as `value`,`year` as label from bigscreen.syf_commerce_target";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        Map<String,Object> res = new HashMap<>();
        res.put("year",year);
        res.put("years",years);
        return AjaxResult.success(res);
    }

    @GetMapping("/listDsTargetData")
    public AjaxResult listDsTargetData(BigDeptVo vo){
        String sql = "select a.`year`,a.`month`,concat(a.`year`,'年',a.`month`,'月') as rq,concat(ROUND(IFNULL(a.bd_target,0)/10000,2),'万') as bd,concat(ROUND(IFNULL(a.cc_target,0)/10000,2),'万') as cc,concat(ROUND(IFNULL(a.cyq_target,0)/10000,2),'万') as cyq,concat(ROUND(IFNULL(b.htfinished,0)/10000,2),'万') as ht,ROUND(IFNULL(b.htfinished,0)/a.bd_target*100,2) as bdrate,ROUND(IFNULL(b.htfinished,0)/a.cc_target*100,2) as ccrate,ROUND(IFNULL(b.htfinished,0)/a.cyq_target*100,2) as cyqrate,a.bd_target as bd_target,a.cc_target as cc_target,a.cyq_target as cyq_target,b.htfinished as htfinished  from bigscreen.syf_commerce_target a left join bigscreen.syf_dept_area_target b on a.`year`=b.`year` and a.`month`=b.`month` and a.area=b.area where a.`year`='"+vo.getYear()+"' order by a.`year` asc,a.`month` asc";
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        String sql_sum = "select '' as `year`,'' as `month`,'合计' as rq,concat(ROUND(sum(IFNULL(a.bd_target,0))/10000,2),'万') as bd,concat(ROUND(SUM(IFNULL(a.cc_target,0))/10000,2),'万') as cc,concat(ROUND(sum(IFNULL(a.cyq_target,0))/10000,2),'万') as cyq,concat(ROUND(sum(IFNULL(b.htfinished,0))/10000,2),'万') as ht,ROUND(SUM(IFNULL(b.htfinished,0))/sum(IFNULL(a.bd_target,0))*100,2) as bdrate,ROUND(SUM(IFNULL(b.htfinished,0))/sum(IFNULL(a.cc_target,0))*100,2) as ccrate,ROUND(SUM(IFNULL(b.htfinished,0))/sum(IFNULL(a.cyq_target,0))*100,2) as cyqrate,'-' as bd_target,'-' as cc_target,'-' as cyq_target,'-' as htfinished from bigscreen.syf_commerce_target a left join bigscreen.syf_dept_area_target b on a.`year`=b.`year` and a.`month`=b.`month` and a.area=b.area where a.`year`='"+vo.getYear()+"'";
        List<Map<String,Object>> summary = sysYyZhouhuiFixedService.selectWeeksInfo(sql_sum);
        List<Map<String,Object>> list = new ArrayList<>();
        list.addAll(res);
        list.addAll(summary);

        String sql_chart = "select a.`year`,a.`month`,concat(a.`year`,'年',a.`month`,'月') as rq,ROUND(IFNULL(a.bd_target,0)/10000,2) as bd,ROUND(IFNULL(a.cc_target,0)/10000,2) as cc,ROUND(IFNULL(a.cyq_target,0)/10000,2) as cyq,ROUND(IFNULL(b.htfinished,0)/10000,2) as ht,ROUND(IFNULL(b.htfinished,0)/a.bd_target*100,2) as bdrate,ROUND(IFNULL(b.htfinished,0)/a.cc_target*100,2) as ccrate,ROUND(IFNULL(b.htfinished,0)/a.cyq_target*100,2) as cyqrate,a.bd_target as bd_target,a.cc_target as cc_target,a.cyq_target as cyq_target,b.htfinished as htfinished  from bigscreen.syf_commerce_target a left join bigscreen.syf_dept_area_target b on a.`year`=b.`year` and a.`month`=b.`month` and a.area=b.area where a.`year`='"+vo.getYear()+"' order by a.`year` asc,a.`month` desc";
        List<Map<String,Object>> chart = sysYyZhouhuiFixedService.selectWeeksInfo(sql_chart);
        Map<String,Object> resMap = new HashMap<>();
        resMap.put("list",list);
        resMap.put("chart",chart);
        return AjaxResult.success(resMap);
    }

    @GetMapping("/listScbSdsjDbDicts")
    public AjaxResult listScbSdsjDbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String initYear = null;
        List<Map<String,Object>> years = new ArrayList<>();
        if(!vo.getqMode().equalsIgnoreCase("yy")){
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            if(vo.getYear()!=null){
                initYear = vo.getYear();
            }else{
                initYear = sdf.format(new Date());
            }
            String sql = "select distinct substr(qd_date,1,4) as `value`,concat(substr(qd_date,1,4),'年') as label from scb_kh_price_stat order by `value` asc";
            years = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }
        res.put("year",initYear);
        res.put("years",years);
        return AjaxResult.success(res);
    }

    @GetMapping("/listHxmxSummary")
    public AjaxResult listHxmxSummary(WeeklyYsVo vo){
        String sql_sum = "";
        if(vo.getArea().equalsIgnoreCase("all")){
            sql_sum = "select count(*) as totalPage from dw.kh_lc_detail where 2025_max_time is not null and 2024_max_time is null";
        }else{
            sql_sum = "select count(*) as totalPage from dw.kh_lc_detail where area='"+vo.getArea()+"' and 2025_max_time is not null and 2024_max_time is null";
        }
        List<Map<String,Object>> countList = sysYyZhouhuiFixedService.selectWeeksInfo(sql_sum);
        int totalPage = 0;
        if(countList.size()>0){
            int total = Integer.parseInt(countList.get(0).get("totalPage").toString());
            int quotient  = total / vo.getPageSize();  // 向零取整的商
            int remainder = total % vo.getPageSize();
            if(remainder>0){
                totalPage = quotient+1;
            }else{
                totalPage = quotient;
            }
        }
        String list_sql = "";
        if(vo.getArea().equalsIgnoreCase("all")){
            list_sql = "select area,`owner` as saleman,kh_name as customer,2020_max_time as zwxd2020,2021_max_time as zwxd2021,2022_max_time as zwxd2022,2023_max_time as zwxd2023,2024_max_time as zwxd2024,2025_max_time as zwxd2025,date_diff as lcts from dw.kh_lc_detail where 2025_max_time is not null and 2024_max_time is null order by area desc,`owner` desc limit "+(vo.getPageNo()-1)*vo.getPageSize()+","+vo.getPageSize();
        }else{
            list_sql = "select area,`owner` as saleman,kh_name as customer,2020_max_time as zwxd2020,2021_max_time as zwxd2021,2022_max_time as zwxd2022,2023_max_time as zwxd2023,2024_max_time as zwxd2024,2025_max_time as zwxd2025,date_diff as lcts from dw.kh_lc_detail where area='"+vo.getArea()+"' and 2025_max_time is not null and 2024_max_time is null order by area desc,`owner` desc limit "+(vo.getPageNo()-1)*vo.getPageSize()+","+vo.getPageSize();
        }
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectWeeksInfo(list_sql);
        Map<String,Object> res = new HashMap<>();
        res.put("list",list);
        res.put("totalPage",totalPage);
        res.put("pageNo",vo.getPageNo());
        res.put("pageSize",vo.getPageSize());
        return AjaxResult.success(res);
    }

    @GetMapping("/listLcmxSummary")
    public AjaxResult listLcmxSummary(WeeklyYsVo vo){
        String sql_sum = "";
        if(vo.getArea().equalsIgnoreCase("all")){
            sql_sum = "select count(*) as totalPage from dw.kh_lc_detail";
        }else{
            sql_sum = "select count(*) as totalPage from dw.kh_lc_detail where area='"+vo.getArea()+"'";
        }
        List<Map<String,Object>> countList = sysYyZhouhuiFixedService.selectWeeksInfo(sql_sum);
        int totalPage = 0;
        if(countList.size()>0){
            int total = Integer.parseInt(countList.get(0).get("totalPage").toString());
            int quotient  = total / vo.getPageSize();  // 向零取整的商
            int remainder = total % vo.getPageSize();
            if(remainder>0){
                totalPage = quotient+1;
            }else{
                totalPage = quotient;
            }
        }
        String list_sql = "";
        if(vo.getArea().equalsIgnoreCase("all")){
            list_sql = "select area,`owner` as saleman,kh_name as customer,2020_max_time as zwxd2020,2021_max_time as zwxd2021,2022_max_time as zwxd2022,2023_max_time as zwxd2023,2024_max_time as zwxd2024,2025_max_time as zwxd2025,date_diff as lcts from dw.kh_lc_detail order by area desc,`owner` desc limit "+(vo.getPageNo()-1)*vo.getPageSize()+","+vo.getPageSize();
        }else{
            list_sql = "select area,`owner` as saleman,kh_name as customer,2020_max_time as zwxd2020,2021_max_time as zwxd2021,2022_max_time as zwxd2022,2023_max_time as zwxd2023,2024_max_time as zwxd2024,2025_max_time as zwxd2025,date_diff as lcts from dw.kh_lc_detail where area='"+vo.getArea()+"' order by area desc,`owner` desc limit "+(vo.getPageNo()-1)*vo.getPageSize()+","+vo.getPageSize();
        }
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectWeeksInfo(list_sql);
        Map<String,Object> res = new HashMap<>();
        res.put("list",list);
        res.put("totalPage",totalPage);
        res.put("pageNo",vo.getPageNo());
        res.put("pageSize",vo.getPageSize());
        return AjaxResult.success(res);
    }

    @GetMapping("/listLchxSummary")
    public AjaxResult listLchxSummary(WeeklyYsVo vo){
        List<Map<String,Object>> res = new ArrayList<>();
        if(vo.getArea().equalsIgnoreCase("all")){
            String dictssql = "select distinct area from(select * from dw.kh_lc_lv order by 2025_xds desc) a order by area desc";
            List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectWeeksInfo(dictssql);
            if(list!=null && list.size()>0){
                for(Map<String,Object> map : list){
                    if(map.get("area")!=null){
                        String area = (String) map.get("area");
                        String sql = "select area,`owner`,2020_xds as xds2020,2021_xds as xds2021,2022_xds as xds2022,2023_xds as xds2023,2024_xds as xds2024,2025_xds as xds2025,21_22_xds as xds2122,22_23_xds as xds2223,23_24_xds as xds2324,24_25_xds as xds2425,2022_lclv as lclv2022,2023_lclv as lclv2023,2024_lclv as lclv2024,2025_lclv as lclv2025 from dw.kh_lc_lv where area='"+area+"' order by 2025_xds desc";
                        List<Map<String,Object>> result = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
                        if(result!=null && result.size()>0){
                            res.addAll(result);
                        }
                    }
                }
            }
        }else{
            String sql = "select area,`owner`,2020_xds as xds2020,2021_xds as xds2021,2022_xds as xds2022,2023_xds as xds2023,2024_xds as xds2024,2025_xds as xds2025,21_22_xds as xds2122,22_23_xds as xds2223,23_24_xds as xds2324,24_25_xds as xds2425,2022_lclv as lclv2022,2023_lclv as lclv2023,2024_lclv as lclv2024,2025_lclv as lclv2025 from dw.kh_lc_lv where area='"+vo.getArea()+"' order by 2025_xds desc";
            List<Map<String,Object>> result = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(result!=null && result.size()>0){
                res.addAll(result);
            }
        }
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("lclv2025")!=null){
                    BigDecimal value = new BigDecimal(map.get("lclv2025").toString()).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                    map.put("lclv2025",value);
                }
                if(map.get("lclv2024")!=null){
                    BigDecimal value = new BigDecimal(map.get("lclv2024").toString()).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                    map.put("lclv2024",value);
                }
                if(map.get("lclv2023")!=null){
                    BigDecimal value = new BigDecimal(map.get("lclv2023").toString()).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                    map.put("lclv2023",value);
                }
                if(map.get("lclv2022")!=null){
                    BigDecimal value = new BigDecimal(map.get("lclv2022").toString()).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
                    map.put("lclv2022",value);
                }
            }
        }
        String hxmx_sql = "";
        if(vo.getArea().equalsIgnoreCase("all")){
            hxmx_sql = "select area,`owner` as saleman,kh_name as customer,2020_max_time as zwxd2020,2021_max_time as zwxd2021,2022_max_time as zwxd2022,2023_max_time as zwxd2023,2024_max_time as zwxd2024,2025_max_time as zwxd2025,date_diff as lcts from dw.kh_lc_detail where 2025_max_time is not null and 2024_max_time is null order by area desc,`owner` desc";
        }else{
            hxmx_sql = "select area,`owner` as saleman,kh_name as customer,2020_max_time as zwxd2020,2021_max_time as zwxd2021,2022_max_time as zwxd2022,2023_max_time as zwxd2023,2024_max_time as zwxd2024,2025_max_time as zwxd2025,date_diff as lcts from dw.kh_lc_detail where area='"+vo.getArea()+"' and 2025_max_time is not null and 2024_max_time is null order by area desc,`owner` desc";
        }
        List<Map<String,Object>> hxmx = sysYyZhouhuiFixedService.selectWeeksInfo(hxmx_sql);
        Map<String,Object> map = new HashMap<>();
        map.put("lclv",res);
        map.put("hxmx",hxmx);
        return AjaxResult.success(map);
    }

    @GetMapping("/listScbXsbDbSummary")
    public AjaxResult listScbXsbDbSummary(BigDeptVo vo){

        String sql_fee = "";
        String sql_rs = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_fee = "select substr(qd_date,1,4) as rq,sum(scb_price) as scb_price,sum(xsb_price) as xsb_price from scb_kh_price_stat  GROUP BY 1 order by rq asc";
            sql_rs = "select substr(create_time,1,4) as rq,sum(scb_khnums) as scb_khnums,sum(xsb_khnums) as xsb_khnums from scb_kh_stat  GROUP BY 1 order by rq asc";
        }else if(vo.getqMode().equalsIgnoreCase("ym")){
            sql_fee = "select y_month as rq,sum(scb_price) as scb_price,sum(xsb_price) as xsb_price from scb_kh_price_stat where qd_date like '%"+vo.getYear()+"%' GROUP BY 1 order by rq asc";
            sql_rs = "select y_month as rq,sum(scb_khnums) as scb_khnums,sum(xsb_khnums) as xsb_khnums from scb_kh_stat where create_time like '%"+vo.getYear()+"%' GROUP BY 1 order by rq asc";
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            sql_fee = "select substr(qd_date,1,4) as rq,week_of_year,sum(scb_price) as scb_price,sum(xsb_price) as xsb_price from scb_kh_price_stat where qd_date like '%"+vo.getYear()+"%'  GROUP BY 1,2 order by rq asc,week_of_year asc";
            sql_rs = "select substr(create_time,1,4) as rq,week_of_year,sum(scb_khnums) as scb_khnums,sum(xsb_khnums) as xsb_khnums from scb_kh_stat where create_time like '%"+vo.getYear()+"%'  GROUP BY 1,2 order by rq asc,week_of_year asc";
        }
        List<Map<String,Object>> fee = sysYyZhouhuiFixedService.selectWeeksInfo(sql_fee);
        List<Map<String,Object>> rs = sysYyZhouhuiFixedService.selectWeeksInfo(sql_rs);
        if(fee.size()>0){
            for(Map<String,Object> map : fee){
                String rq = "";
                if(vo.getqMode().equalsIgnoreCase("yy")){
                    rq = map.get("rq").toString()+"年";
                }else if(vo.getqMode().equalsIgnoreCase("ym")){
                    rq = map.get("rq").toString().replaceAll("-","年")+"月";
                }else if(vo.getqMode().equalsIgnoreCase("wk")){
                    rq = map.get("rq").toString()+"年第"+map.get("week_of_year").toString()+"周";
                }
                map.put("rq",rq);
                String rate = "";
                if(map.get("scb_price")!=null&&map.get("xsb_price")!=null){
                    BigDecimal scb = new BigDecimal(map.get("scb_price").toString());
                    BigDecimal xsb = new BigDecimal(map.get("xsb_price").toString());
                    BigDecimal scbn = scb.divide(new BigDecimal(10000),2,BigDecimal.ROUND_HALF_UP);
                    BigDecimal xsbn = xsb.divide(new BigDecimal(10000),2,BigDecimal.ROUND_HALF_UP);
                    map.put("scb_price",scbn);
                    map.put("xsb_price",xsbn);
                    BigDecimal raten = scb.divide(xsb,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    rate = "-"+raten.toString();
                }
                map.put("rate",rate);
            }
        }
        if(rs.size()>0){
            for(Map<String,Object> map : rs){
                String rq = "";
                if(vo.getqMode().equalsIgnoreCase("yy")){
                    rq = map.get("rq").toString()+"年";
                }else if(vo.getqMode().equalsIgnoreCase("ym")){
                    rq = map.get("rq").toString().replaceAll("-","年")+"月";
                }else if(vo.getqMode().equalsIgnoreCase("wk")){
                    rq = map.get("rq").toString()+"年第"+map.get("week_of_year").toString()+"周";
                }
                map.put("rq",rq);
                String rate = "";
                if(map.get("scb_khnums")!=null&&map.get("xsb_khnums")!=null){
                    BigDecimal scb = new BigDecimal(map.get("scb_khnums").toString());
                    BigDecimal xsb = new BigDecimal(map.get("xsb_khnums").toString());
                    BigDecimal raten = scb.divide(xsb,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    rate = "-"+raten.toString();
                }
                map.put("rate",rate);
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("fee",fee);
        res.put("rs",rs);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXmiSdsjSummary")
    public AjaxResult listXmiSdsjSummary(BigDeptVo vo){
        String sql = "";
        String sql_db = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            if(vo.getType().equalsIgnoreCase("brand")){
                sql = "select * from scb_first_transform where target='brand-"+vo.getqMode()+"' and brand='"+vo.getBrand()+"' order by tag_date asc";
            }else{
                sql = "select * from scb_first_transform where target='bigname-"+vo.getqMode()+"' and brand='"+vo.getBrand()+"' and bigname='"+vo.getBigname()+"' order by tag_date asc";
            }
            sql_db = "select * from scb_kh_price_stat_brand where tag='brand-"+vo.getqMode()+"' and brand='"+vo.getBrand()+"' order by tag_date asc";
        }else{
            if(vo.getType().equalsIgnoreCase("brand")){
                sql = "select * from scb_first_transform where target='brand-"+vo.getqMode()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
            }else{
                sql = "select * from scb_first_transform where target='bigname-"+vo.getqMode()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' and bigname='"+vo.getBigname()+"' order by tag_date asc";
            }
            sql_db = "select * from scb_kh_price_stat_brand where tag='brand-"+vo.getqMode()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
        }
        List<Map<String,Object>> sdsj = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        List<Map<String,Object>> scxsdb = sysYyZhouhuiFixedService.selectWeeksInfo(sql_db);
        Map<String,Object> res = new HashMap<>();
        res.put("sdsj",sdsj);
        res.put("scxsdb",scxsdb);
        return AjaxResult.success(res);
    }

    @GetMapping("/listScbSdsjDicts")
    public AjaxResult listScbSdsjDicts(BigDeptVo vo){
        List<Map<String,Object>> years = new ArrayList<>();
        String initYear = "";
        if(!vo.getqMode().equalsIgnoreCase("yy")){
            String sql = "select distinct substr(tag_date,1,4) as `value`,concat(substr(tag_date,1,4),'年') as label from scb_first_transform where substr(tag_date,1,4)>='2023' order by `value` asc";
            years = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(vo.getYear()!=null){
                initYear = vo.getYear();
            }else{
                if(years.size()>0){
                    initYear = years.get(years.size()-1).get("value").toString();
                }
            }
        }
        String brand_sql = "select distinct brand as `value`,brand as label from scb_first_transform where tag_date like '%"+initYear+"%' and target='brand-"+vo.getqMode()+"' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            if(brands.size()>0){
                initBrand = brands.get(0).get("value").toString();
            }
        }

        List<Map<String,Object>> bignames = new ArrayList<>();
        if(vo.getType().equalsIgnoreCase("bigname")){
            String sql = "select distinct bigname as `value`,bigname as label from scb_first_transform where brand='"+initBrand+"' and tag_date like '%"+initYear+"%' and target='bigname-"+vo.getqMode()+"'";
            bignames = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }
        String initBigname = "";
        if(vo.getBigname()!=null){
            initBigname = vo.getBigname();
        }else{
            if(bignames.size()>0){
                initBigname = bignames.get(0).get("value").toString();
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("year",initYear);
        res.put("years",years);
        res.put("brand",initBrand);
        res.put("brands",brands);
        res.put("bigname",initBigname);
        res.put("bignames",bignames);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbBigDptBrandSummary")
    public AjaxResult listXsbBigDptBrandSummary(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='yy-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and cls='ht' order by brand desc";
            sql_ck = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='yy-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and cls='ck' order by brand desc";
            sql_pht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='yy-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and cls='pht' order by brand desc";
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            sql_ht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='yq-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ht' order by brand desc";
            sql_ck = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='yq-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ck' order by brand desc";
            sql_pht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='yq-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='pht' order by brand desc";
        }else if(vo.getqMode().equalsIgnoreCase("ym")){
            sql_ht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='ym-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ht' order by brand asc";
            sql_ck = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='ym-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ck' order by brand asc";
            sql_pht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='ym-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='pht' order by brand asc";
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            sql_ht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='wk-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ht' order by brand desc";
            sql_ck = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='wk-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ck' order by brand desc";
            sql_pht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='wk-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='pht' order by brand desc";
        }
        List<Map<String,Object>> list_ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> list_ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> list_pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(list_ht.size()>0){
            for (Map<String,Object> map : list_ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(list_ck.size()>0){
            for (Map<String,Object> map : list_ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(list_pht.size()>0){
            for (Map<String,Object> map : list_pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        res.put("ht", list_ht);
        res.put("ck", list_ck);
        res.put("pht", list_pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listBigDptBrandSummary")
    public AjaxResult listBigDptBrandSummary(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='yy-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and cls='ht' order by brand desc";
            sql_ck = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='yy-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and cls='ck' order by brand desc";
            sql_pht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='yy-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and cls='pht' order by brand desc";
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            sql_ht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='yq-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ht' order by brand desc";
            sql_ck = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='yq-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ck' order by brand desc";
            sql_pht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='yq-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='pht' order by brand desc";
        }else if(vo.getqMode().equalsIgnoreCase("ym")){
            sql_ht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='ym-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ht' order by brand asc";
            sql_ck = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='ym-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ck' order by brand asc";
            sql_pht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='ym-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='pht' order by brand asc";
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            sql_ht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='wk-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ht' order by brand desc";
            sql_ck = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='wk-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='ck' order by brand desc";
            sql_pht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='wk-bigdpt-brand' and tag_date like '%"+vo.getYear()+"%' and tag_date='"+vo.getSubTime()+"' and cls='pht' order by brand desc";
        }
        List<Map<String,Object>> list_ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> list_ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> list_pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(list_ht.size()>0){
            for (Map<String,Object> map : list_ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(list_ck.size()>0){
            for (Map<String,Object> map : list_ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(list_pht.size()>0){
            for (Map<String,Object> map : list_pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        res.put("ht", list_ht);
        res.put("ck", list_ck);
        res.put("pht", list_pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbThirdDataSummary")
    public AjaxResult listXsbThirdDataSummary(BigDeptVo vo){
        String sql = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' and cls='"+vo.getType()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
        }else{
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' and cls='"+vo.getType()+"' and dpt='"+vo.getDpt()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listThirdDataSummary")
    public AjaxResult listThirdDataSummary(BigDeptVo vo){
        String sql = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' and cls='"+vo.getType()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
        }else{
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' and cls='"+vo.getType()+"' and dpt='"+vo.getDpt()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbSecondDataSummary")
    public AjaxResult listXsbSecondDataSummary(BigDeptVo vo){
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ht' and tag_date='"+vo.getYear()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ck' and tag_date='"+vo.getYear()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='pht' and tag_date='"+vo.getYear()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
        }else{
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ht' and tag_date='"+vo.getSubTime()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ck' and tag_date='"+vo.getSubTime()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='pht' and tag_date='"+vo.getSubTime()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
        }
        List<Map<String,Object>> ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(ht.size()>0){
            for (Map<String,Object> map : ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(ck.size()>0){
            for (Map<String,Object> map : ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(pht.size()>0){
            for (Map<String,Object> map : pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("ht", ht);
        res.put("ck", ck);
        res.put("pht", pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listSecondDataSummary")
    public AjaxResult listSecondDataSummary(BigDeptVo vo){
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ht' and tag_date='"+vo.getYear()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ck' and tag_date='"+vo.getYear()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='pht' and tag_date='"+vo.getYear()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
        }else{
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ht' and tag_date='"+vo.getSubTime()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='ck' and tag_date='"+vo.getSubTime()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='pht' and tag_date='"+vo.getSubTime()+"' and dpt='"+vo.getDpt()+"' order by tag_date asc";
        }
        List<Map<String,Object>> ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(ht.size()>0){
            for (Map<String,Object> map : ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(ck.size()>0){
            for (Map<String,Object> map : ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(pht.size()>0){
            for (Map<String,Object> map : pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("ht", ht);
        res.put("ck", ck);
        res.put("pht", pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listFirstDataSummary")
    public AjaxResult listFirstDataSummary(BigDeptVo vo){
        String sql = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and dpt like '%"+vo.getDpt()+"%' order by tag_date asc";
        }else{
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and dpt like '%"+vo.getDpt()+"%' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbFirstDataSummary")
    public AjaxResult listXsbFirstDataSummary(BigDeptVo vo){
        String sql = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and dpt like '%"+vo.getDpt()+"%' order by tag_date asc";
        }else{
            sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-brand' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and dpt like '%"+vo.getDpt()+"%' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbBigBrandSummary")
    public AjaxResult listXsbBigBrandSummary(BigDeptVo vo){
        List<Map<String,Object>> res = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("yy")){
            String sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='销售部' and target='yy-bigdpt-brand' and cls='"+vo.getType()+"' and brand='"+vo.getBrand()+"' order by tag_date asc";
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            String sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='销售部' and target='yq-bigdpt-brand' and cls='"+vo.getType()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }else if(vo.getqMode().equalsIgnoreCase("ym")){
            String year = vo.getYear();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            String cYear = sdf.format(new Date());
            String sql = "";
            if(year.equals(cYear)){
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
                String cMonth = sdf1.format(new Date());
                sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='销售部' and cls='"+vo.getType()+"' and target='ym-bigdpt-brand' and  tag_date like '%"+year+"%' and tag_date<='"+cMonth+"' and brand='"+vo.getBrand()+"' order by tag_date asc";
            }else{
                sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='销售部' and cls='"+vo.getType()+"' and target='ym-bigdpt-brand' and  tag_date like '%"+year+"%' and brand='"+vo.getBrand()+"' order by tag_date asc";
            }
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            String sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='销售部' and target='wk-bigdpt-brand' and cls='"+vo.getType()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listBigBrandSummary")
    public AjaxResult listBigBrandSummary(BigDeptVo vo){
        List<Map<String,Object>> res = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("yy")){
            String sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='电商' and target='yy-bigdpt-brand' and cls='"+vo.getType()+"' and brand='"+vo.getBrand()+"' order by tag_date asc";
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            String sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='电商' and target='yq-bigdpt-brand' and cls='"+vo.getType()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }else if(vo.getqMode().equalsIgnoreCase("ym")){
            String year = vo.getYear();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
            String cYear = sdf.format(new Date());
            String sql = "";
            if(year.equals(cYear)){
                SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM");
                String cMonth = sdf1.format(new Date());
                sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='电商' and cls='"+vo.getType()+"' and target='ym-bigdpt-brand' and  tag_date like '%"+year+"%' and tag_date<='"+cMonth+"' and brand='"+vo.getBrand()+"' order by tag_date asc";
            }else{
                sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='电商' and cls='"+vo.getType()+"' and target='ym-bigdpt-brand' and  tag_date like '%"+year+"%' and brand='"+vo.getBrand()+"' order by tag_date asc";
            }
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            String sql = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt='电商' and target='wk-bigdpt-brand' and cls='"+vo.getType()+"' and brand='"+vo.getBrand()+"' and tag_date like '%"+vo.getYear()+"%' order by tag_date asc";
            res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        }
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbYjbmBignameSummary")
    public AjaxResult listXsbYjbmBignameSummary(BigDeptVo vo){
        String sql = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' order by tag_date asc";
        }else{
            sql = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' and tag_date like '%"+vo.getYear()+"%'  order by tag_date asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listYjbmBignameSummary")
    public AjaxResult listYjbmBignameSummary(BigDeptVo vo){
        String sql = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' order by tag_date asc";
        }else{
            sql = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='"+vo.getType()+"' and trg_brd='"+vo.getBrand()+"' and brand='"+vo.getBigname()+"' and tag_date like '%"+vo.getYear()+"%'  order by tag_date asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        if(res.size()>0){
            for(Map<String,Object> map : res){
                if(map.get("tag_date")!=null){
                    String tagDate = "";
                    if(vo.getqMode().equalsIgnoreCase("yy")){
                        tagDate = map.get("tag_date").toString()+"年";
                    }else if(vo.getqMode().equalsIgnoreCase("ym")){
                        tagDate = map.get("tag_date").toString().replaceAll("-","年")+"月";
                    }else if(vo.getqMode().equalsIgnoreCase("yq")){
                        tagDate = map.get("tag_date").toString().replaceAll("_","年第")+"季度";
                    }else if(vo.getqMode().equalsIgnoreCase("wk")){
                        tagDate = vo.getYear()+"年第"+map.get("tag_date").toString().split("_")[1].replaceAll("wk","")+"周";
                    }
                    map.put("tag_date", tagDate);
                }
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("bmmoneyrate", bmmoneyrate);
                }
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbEjbmBignameFourthSummary")
    public AjaxResult listXsbEjbmBignameFourthSummary(BigDeptVo vo){
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ck' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='pht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
        }else{
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ck' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='pht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
        }
        List<Map<String,Object>> ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(ht.size()>0){
            for (Map<String,Object> map : ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(ck.size()>0){
            for (Map<String,Object> map : ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(pht.size()>0){
            for (Map<String,Object> map : pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("ht", ht);
        res.put("ck", ck);
        res.put("pht", pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listEjbmBignameFourthSummary")
    public AjaxResult listEjbmBignameFourthSummary(BigDeptVo vo){
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ck' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='pht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
        }else{
            sql_ht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_ck = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='ck' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
            sql_pht = "select * from zhouhui_prev where target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and cls='pht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' and dpt='"+vo.getDpt()+"' order by qty asc";
        }
        List<Map<String,Object>> ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(ht.size()>0){
            for (Map<String,Object> map : ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(ck.size()>0){
            for (Map<String,Object> map : ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(pht.size()>0){
            for (Map<String,Object> map : pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("ht", ht);
        res.put("ck", ck);
        res.put("pht", pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbBingnamePlzbSummary")
    public AjaxResult listXsbBingnamePlzbSummary(BigDeptVo vo){
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_ck = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ck' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_pht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='pht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
        }else{
            sql_ht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_ck = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ck' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_pht = "select * from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='pht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
        }
        List<Map<String,Object>> ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(ht.size()>0){
            for (Map<String,Object> map : ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(ck.size()>0){
            for (Map<String,Object> map : ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(pht.size()>0){
            for (Map<String,Object> map : pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("ht", ht);
        res.put("ck", ck);
        res.put("pht", pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listBingnamePlzbSummary")
    public AjaxResult listBingnamePlzbSummary(BigDeptVo vo){
        String sql_ht = "";
        String sql_ck = "";
        String sql_pht = "";
        if(vo.getqMode().equalsIgnoreCase("yy")){
            sql_ht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_ck = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ck' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_pht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='pht' and tag_date='"+vo.getYear()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
        }else{
            sql_ht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_ck = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='ck' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
            sql_pht = "select * from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and cls='pht' and tag_date='"+vo.getSubTime()+"' and trg_brd='"+vo.getBrand()+"' order by money asc";
        }
        List<Map<String,Object>> ht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ht);
        List<Map<String,Object>> ck = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);
        List<Map<String,Object>> pht = sysYyZhouhuiFixedService.selectWeeksInfo(sql_pht);
        if(ht.size()>0){
            for (Map<String,Object> map : ht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(ck.size()>0){
            for (Map<String,Object> map : ck) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        if(pht.size()>0){
            for (Map<String,Object> map : pht) {
                if(map.get("total_qty_brd")!=null&&(new BigDecimal(map.get("total_qty_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmqtyrate = new BigDecimal(map.get("qty").toString()).divide(new BigDecimal(map.get("total_qty_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plqtyrate", bmqtyrate);
                }
                if(map.get("total_money_brd")!=null&&(new BigDecimal(map.get("total_money_brd").toString()).compareTo(new BigDecimal("0"))>0)){
                    BigDecimal bmmoneyrate = new BigDecimal(map.get("money").toString()).divide(new BigDecimal(map.get("total_money_brd").toString()),4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100")).setScale(2,BigDecimal.ROUND_HALF_UP);
                    map.put("plmoneyrate", bmmoneyrate);
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("ht", ht);
        res.put("ck", ck);
        res.put("pht", pht);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbEjbmBignameDicts")
    public AjaxResult listXsbEjbmBignameDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value`,target_1 as label from zhouhui_prev where dpt not like '%电商%' and target like '%dpt-bigname%' order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }

        String sql_bigname = "SELECT distinct brand as `value`,brand as label from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> bignames = sysYyZhouhuiFixedService.selectWeeksInfo(sql_bigname);
        String initBigname = "";
        if(vo.getBigname()!=null){
            initBigname = vo.getBigname();
        }else{
            initBigname = "大飞燕";
        }

        String type_sql = "select distinct cls as `value`,cls as label from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(type_sql);
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        String initType = "";
        if(vo.getType()!=null){
            initType = vo.getType();
        }else{
            initType = types.get(0).get("value").toString();
        }

        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' and cls='"+initType+"' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            initDpt = dpts.get(0).get("value").toString();
        }

        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("bigname", initBigname);
        res.put("bignames", bignames);
        res.put("type", initType);
        res.put("types", types);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listEjbmBignameDicts")
    public AjaxResult listEjbmBignameDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value`,target_1 as label from zhouhui_prev where dpt like '%电商%' and target like '%dpt-bigname%' order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }

        String sql_bigname = "SELECT distinct brand as `value`,brand as label from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> bignames = sysYyZhouhuiFixedService.selectWeeksInfo(sql_bigname);
        String initBigname = "";
        if(vo.getBigname()!=null){
            initBigname = vo.getBigname();
        }else{
            initBigname = "大飞燕";
        }

        String type_sql = "select distinct cls as `value`,cls as label from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(type_sql);
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        String initType = "";
        if(vo.getType()!=null){
            initType = vo.getType();
        }else{
            initType = types.get(0).get("value").toString();
        }

        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' and cls='"+initType+"' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            initDpt = dpts.get(0).get("value").toString();
        }

        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("bigname", initBigname);
        res.put("bignames", bignames);
        res.put("type", initType);
        res.put("types", types);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbEjbmPlzbDicts")
    public AjaxResult listXsbEjbmPlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value`,target_1 as label from zhouhui_prev where dpt not like '%电商%' and target like '%dpt-brand%' order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }

        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            initDpt = dpts.get(0).get("value").toString();
        }

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and target ='"+vo.getqMode()+"-dpt-brand' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt not like '%电商%' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listEjbmPlzbDicts")
    public AjaxResult listEjbmPlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value`,target_1 as label from zhouhui_prev where dpt like '%电商%' and target like '%dpt-brand%' order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }

        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            initDpt = dpts.get(0).get("value").toString();
        }

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and target ='"+vo.getqMode()+"-dpt-brand' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and target ='"+vo.getqMode()+"-dpt-brand' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt like '%电商%' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbEjbmDicts")
    public AjaxResult listXsbEjbmDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value`,target_1 as label from zhouhui_prev where dpt not like '%电商%' and target like '%dpt-brand%' order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }

        String type_sql = "select distinct cls as `value`,cls as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(type_sql);
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        String initType = "";
        if(vo.getType()!=null){
            initType = vo.getType();
        }else{
            initType = types.get(0).get("value").toString();
        }

        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            initDpt = dpts.get(0).get("value").toString();
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("type", initType);
        res.put("types", types);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listEjbmDicts")
    public AjaxResult listEjbmDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value`,target_1 as label from zhouhui_prev where dpt like '%电商%' and target like '%dpt-brand%' order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }

        String type_sql = "select distinct cls as `value`,cls as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(type_sql);
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        String initType = "";
        if(vo.getType()!=null){
            initType = vo.getType();
        }else{
            initType = types.get(0).get("value").toString();
        }

        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-brand' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            initDpt = dpts.get(0).get("value").toString();
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("type", initType);
        res.put("types", types);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbEjbmBignamePlzbDicts")
    public AjaxResult listXsbEjbmBignamePlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }
        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt not like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            if(dpts.size()>0){
                initDpt = dpts.get(0).get("value").toString();
            }else {
                initDpt = "";
            }
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }


    @GetMapping("/listEjbmBignamePlzbDicts")
    public AjaxResult listEjbmBignamePlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }

        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }
        String dpt_sql = "select distinct dpt as `value`,dpt as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and dpt like '%电商%' and target ='"+vo.getqMode()+"-dpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> dpts = sysYyZhouhuiFixedService.selectWeeksInfo(dpt_sql);
        String initDpt = "";
        if(vo.getDpt()!=null){
            initDpt = vo.getDpt();
        }else{
            if(dpts.size()>0){
                initDpt = dpts.get(0).get("value").toString();
            }else {
                initDpt = "";
            }
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brand", initBrand);
        res.put("brands", brands);
        res.put("dpt", initDpt);
        res.put("dpts", dpts);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbYjbmBignamePlzbDicts")
    public AjaxResult listXsbYjbmBignamePlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+year+"%' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brands", brands);
        res.put("brand", brands.get(0).get("value").toString());
        return AjaxResult.success(res);
    }

    @GetMapping("/listYjbmBignamePlzbDicts")
    public AjaxResult listYjbmBignamePlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+year+"%' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brands", brands);
        res.put("brand", brands.get(0).get("value").toString());
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbYjbmBignameDicts")
    public AjaxResult listXsbYjbmBignameDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }
        String sql_brands = "SELECT distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and tag_date like '%"+inityear+"%' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(sql_brands);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }
        String sql_bigname = "SELECT distinct brand as `value`,brand as label from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> bignames = sysYyZhouhuiFixedService.selectWeeksInfo(sql_bigname);
        String initBigname = "";
        if(vo.getBigname()!=null){
            initBigname = vo.getBigname();
        }else{
            initBigname = bignames.get(0).get("value").toString();
        }
        String sql_type = "SELECT distinct cls as `value`,cls as label from zhouhui_prev where dpt='销售部' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' and brand='"+initBigname+"' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(sql_type);
        String initType = "";
        if(vo.getType()!=null){
            initType = vo.getType();
        }else{
            initType = types.get(0).get("value").toString();
        }
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brands", brands);
        res.put("brand", initBrand);
        res.put("bignames", bignames);
        res.put("bigname", initBigname);
        res.put("types", types);
        res.put("type", initType);
        return AjaxResult.success(res);
    }

    @GetMapping("/listYjbmBignameDicts")
    public AjaxResult listYjbmBignameDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }
        String sql_brands = "SELECT distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and tag_date like '%"+inityear+"%' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(sql_brands);
        String initBrand = "";
        if(vo.getBrand()!=null){
            initBrand = vo.getBrand();
        }else{
            initBrand = brands.get(0).get("value").toString();
        }
        String sql_bigname = "SELECT distinct brand as `value`,brand as label from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' order by `value` asc";
        List<Map<String,Object>> bignames = sysYyZhouhuiFixedService.selectWeeksInfo(sql_bigname);
        String initBigname = "";
        if(vo.getBigname()!=null){
            initBigname = vo.getBigname();
        }else{
            initBigname = bignames.get(0).get("value").toString();
        }
        String sql_type = "SELECT distinct cls as `value`,cls as label from zhouhui_prev where dpt='电商' and target_1='"+vo.getqMode()+"' and target='"+vo.getqMode()+"-bigdpt-bigname' and tag_date like '%"+inityear+"%' and trg_brd='"+initBrand+"' and brand='"+initBigname+"' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(sql_type);
        String initType = "";
        if(vo.getType()!=null){
            initType = vo.getType();
        }else{
            initType = types.get(0).get("value").toString();
        }
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        res.put("modes", modes);
        res.put("year", inityear);
        res.put("years", years);
        res.put("brands", brands);
        res.put("brand", initBrand);
        res.put("bignames", bignames);
        res.put("bigname", initBigname);
        res.put("types", types);
        res.put("type", initType);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbYjbmPlzbDicts")
    public AjaxResult listXsbYjbmPlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        res.put("year", inityear);
        res.put("modes", modes);
        res.put("years", years);
        return AjaxResult.success(res);
    }

    @GetMapping("/listYjbmPlzbDicts")
    public AjaxResult listYjbmPlzbDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        String inityear = "";
        if(vo.getYear()!=null){
            inityear = vo.getYear();
        }else{
            if(years.size()>0){
                inityear = years.get(years.size()-1).get("value").toString();
            }
        }
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
        String cMonth = sdf2.format(new Date());
        String sql = "";
        List<Map<String,Object>> subTimes = new ArrayList<>();
        if(vo.getqMode().equalsIgnoreCase("ym")){
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+cMonth+"' order by `value`";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'-','年'),'月') as label  from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value`";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("yq")){
            LocalDate localDate = LocalDate.now();
            int season = (localDate.getMonthValue()-1)/3+1;
            String yearseason = inityear+"_"+season;
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and tag_date<='"+yearseason+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,concat(REPLACE(tag_date,'_','年第'),'季度') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }else if(vo.getqMode().equalsIgnoreCase("wk")){
            SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd");
            String day = sdf3.format(new Date());
            if(year.equalsIgnoreCase(inityear)){
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' and _date<='"+day+"' order by `value` asc";
            }else{
                sql = "select distinct tag_date as `value`,tag_date as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+inityear+"%' order by `value` asc";
            }
            subTimes = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
            if(subTimes.size()>0){
                for(Map<String,Object> subTime : subTimes){
                    String label = inityear+"年第"+subTime.get("label").toString().split("_")[1].replaceAll("wk","周");
                    subTime.put("label", label);
                }
            }
            res.put("subTimes", subTimes);
            if(vo.getSubTime()!=null){
                res.put("subTime", vo.getSubTime());
            }else{
                res.put("subTime", subTimes.get(subTimes.size()-1).get("value").toString());
            }
        }
        res.put("year", inityear);
        res.put("modes", modes);
        res.put("years", years);
        return AjaxResult.success(res);
    }

    @GetMapping("/listXsbYjbmDicts")
    public AjaxResult listXsbYjbmDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        List<Map<String,Object>> years = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        if(!vo.getqMode().equalsIgnoreCase("yy")){
            String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
            years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        }
        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+year+"%' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String type_sql = "select distinct cls as `value`,cls as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+year+"%' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(type_sql);
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        res.put("modes", modes);
        res.put("years", years);
        res.put("year", year);
        res.put("brands", brands);
        res.put("brand", brands.get(0).get("value").toString());
        res.put("types", types);
        res.put("type", "ht");
        return AjaxResult.success(res);
    }

    @GetMapping("/listYjbmDicts")
    public AjaxResult listYjbmDicts(BigDeptVo vo){
        Map<String,Object> res = new HashMap<>();
        String mode_sql = "select distinct target_1 as `value` from zhouhui_prev order by `value` desc";
        List<Map<String,Object>> modes = sysYyZhouhuiFixedService.selectWeeksInfo(mode_sql);
        if(modes.size()>0){
            for(Map<String,Object> map : modes){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("yy")){
                        map.put("label","年");
                    }else if(map.get("value").toString().equalsIgnoreCase("yq")){
                        map.put("label","季");
                    }else if(map.get("value").toString().equalsIgnoreCase("ym")){
                        map.put("label","月");
                    }else if(map.get("value").toString().equalsIgnoreCase("wk")){
                        map.put("label","周");
                    }
                }
            }
        }
        List<Map<String,Object>> years = new ArrayList<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        if(!vo.getqMode().equalsIgnoreCase("yy")){
            String year_sql = "select distinct SUBSTRING(tag_date,1,4) as `value`,concat(SUBSTRING(tag_date,1,4),'年') as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and SUBSTRING(tag_date,1,4)<='"+year+"' order by `value` asc";
            years = sysYyZhouhuiFixedService.selectWeeksInfo(year_sql);
        }
        String brand_sql = "select distinct trg_brd as `value`,trg_brd as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+year+"%' order by `value` desc";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectWeeksInfo(brand_sql);
        String type_sql = "select distinct cls as `value`,cls as label from zhouhui_prev where target_1='"+vo.getqMode()+"' and tag_date like '%"+year+"%' order by `value` asc";
        List<Map<String,Object>> types = sysYyZhouhuiFixedService.selectWeeksInfo(type_sql);
        if(types.size()>0){
            for(Map<String,Object> map : types){
                if(map.get("value")!=null){
                    if(map.get("value").toString().equalsIgnoreCase("ht")){
                        map.put("label","合同");
                    }else if(map.get("value").toString().equalsIgnoreCase("ck")){
                        map.put("label","出库");
                    }else if(map.get("value").toString().equalsIgnoreCase("pht")){
                        map.put("label","预出库");
                    }
                }
            }
        }
        res.put("modes", modes);
        res.put("years", years);
        res.put("year", year);
        res.put("brands", brands);
        res.put("brand", brands.get(0).get("value").toString());
        res.put("types", types);
        res.put("type", "ht");
        return AjaxResult.success(res);
    }

    @GetMapping("/listFszhDicts")
    public AjaxResult listFszhDicts(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        Map<String,Object> res = new HashMap<>();
        String sql_year = "select distinct SUBSTR(seldate,1,4) as `value`,SUBSTR(seldate,1,4) as label from dw.scb_fans_transfrom_part1 where SUBSTR(seldate,1,4)<='"+year+"' order by `value` asc";
        String sql_palt = "select distinct platform as `value`,platform as label from dw.scb_fans_transfrom_part1";
        String sql_orderType = "select distinct type1 as `value`,type1 as label from dw.scb_fans_transfrom_part1 where type1 is not null";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(sql_year);
        List<Map<String,Object>> platforms = sysYyZhouhuiFixedService.selectWeeksInfo(sql_palt);
        List<Map<String,Object>> fplatforms = new ArrayList<>();
        Map<String,Object> fplatform = new HashMap<>();
        fplatform.put("value","all");
        fplatform.put("label","(全部)");
        fplatforms.add(fplatform);
        if(platforms.size()>0){
            fplatforms.addAll(platforms);
        }
        List<Map<String,Object>> ordertypes = sysYyZhouhuiFixedService.selectWeeksInfo(sql_orderType);
        List<Map<String,Object>> fordertypes = new ArrayList<>();
        Map<String,Object> forder = new HashMap<>();
        forder.put("value","all");
        forder.put("label","(全部)");
        fordertypes.add(forder);
        if(ordertypes.size()>0){
            fordertypes.addAll(ordertypes);
        }
        res.put("years",years);
        res.put("platforms",fplatforms);
        res.put("ordertypes",fordertypes);
        res.put("year",year);
        res.put("mode","m");
        return AjaxResult.success(res);
    }

    @GetMapping("/listFszhPart1Summary")
    public AjaxResult listFszhPart1Summary(YxFansVo vo){
        String cls = "";
        if(vo.getMode().equals("y")){
            cls = "ht-y";
        }else if(vo.getMode().equals("m")){
            cls = "ht-ym";
        }else if(vo.getMode().equals("w")){
            cls = "ht-w";
        }

        String sql_plat = "select platform,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate like '%"+vo.getYear()+"%' and cls='"+cls+"' GROUP BY 1 order by customers desc";
        List<Map<String,Object>> plats = sysYyZhouhuiFixedService.selectWeeksInfo(sql_plat);

        String sql_xszje = "select type1,count(distinct customer_id),sum(money) as fee from dw.scb_fans_transfrom_part1 where seldate like '%"+vo.getYear()+"%' and cls='"+cls+"' GROUP BY 1 order by type1 desc";
        List<Map<String,Object>> xszje = sysYyZhouhuiFixedService.selectWeeksInfo(sql_xszje);

        String sql_xsrjje = "select type1,sum(money)/count(distinct customer_id) as fee from dw.scb_fans_transfrom_part1 where seldate like '%"+vo.getYear()+"%' and cls='"+cls+"' GROUP BY 1 order by type1 desc";
        List<Map<String,Object>> xsrjje = sysYyZhouhuiFixedService.selectWeeksInfo(sql_xsrjje);

        String sql_hxff = "select sum(money) as sumfee,sum(money)/count(distinct customer_id) as avgfee from dw.scb_fans_transfrom_part1 where type1!='首次签单金额' and seldate like '%"+vo.getYear()+"%' and cls='"+cls+"'";
        List<Map<String,Object>> hxff = sysYyZhouhuiFixedService.selectWeeksInfo(sql_hxff);
        String sql_region = "select region,count(distinct customer_id) as customers from scb_fans_transfrom_part1 where type1='首次签单金额' and seldate like '%"+vo.getYear()+"%' and cls='"+cls+"' GROUP BY 1 order by customers desc";
        List<Map<String,Object>> region = sysYyZhouhuiFixedService.selectWeeksInfo(sql_region);
        Map<String,Object> res = new HashMap<>();
        res.put("plats",plats);
        res.put("xszje",xszje);
        res.put("xsrjje",xsrjje);
        res.put("hxff",hxff);
        res.put("region",region);
        return AjaxResult.success(res);
    }

    @GetMapping("/listYearWeeks")
    public AjaxResult listYearWeeks(){
        String sql = "select distinct concat(substr(seldate,1,4),'年第',replace(substr(seldate,12),'wk',''),'周') as label,concat(substr(seldate,1,4),'-',replace(substr(seldate,12),'wk','')) as value,cast(substr(seldate,1,4) AS SIGNED) as years,cast(replace(substr(seldate,12),'wk','') AS SIGNED) as weeks from scb_fans_transfrom_part1 where cls='ht-w' order by years desc,weeks desc";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        Map<String,Object> res = new HashMap<>();
        res.put("list",list);
        res.put("startWeek",year+"-53");
        res.put("startWeek",year+"-53");
        return AjaxResult.success();
    }

    @GetMapping("/listFszhPart3Summary")
    public AjaxResult listFszhPart3Summary(YxFansVo vo){
        logger.info("-------mode----------"+vo.getMode());
        logger.info("-------startYear----------"+vo.getStartYear());
        logger.info("-------endYear----------"+vo.getEndYear());
        logger.info("-------startMonth----------"+vo.getStartMonth());
        logger.info("-------endMonth----------"+vo.getEndMonth());
        logger.info("-------weekyear----------"+vo.getWeekyear());
        logger.info("-------platform----------"+vo.getPlatform());
        String sql_fszz = "";
        String sql_qdje = "";
        String sql_ckje = "";
        if(vo.getMode().equalsIgnoreCase("y")){
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_fszz = "select seldate,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-y' and seldate>='"+vo.getStartYear()+"' and seldate<='"+vo.getEndYear()+"' GROUP BY 1 order by seldate asc";
            }else{
                sql_fszz = "select seldate,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-y' and seldate>='"+vo.getStartYear()+"' and seldate<='"+vo.getEndYear()+"' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_qdje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-y' and seldate>='"+vo.getStartYear()+"' and seldate<='"+vo.getEndYear()+"' GROUP BY 1 order by seldate asc";
            }else{
                sql_qdje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-y' and seldate>='"+vo.getStartYear()+"' and seldate<='"+vo.getEndYear()+"' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_ckje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ck-y' and seldate>='"+vo.getStartYear()+"' and seldate<='"+vo.getEndYear()+"' GROUP BY 1 order by seldate asc";
            }else{
                sql_ckje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ck-y' and seldate>='"+vo.getStartYear()+"' and seldate<='"+vo.getEndYear()+"' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
        }else if(vo.getMode().equalsIgnoreCase("m")){
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_fszz = "select seldate,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-ym' and seldate>='"+vo.getStartMonth()+"' and seldate<='"+vo.getEndMonth()+"' GROUP BY 1 order by seldate asc";
            }else{
                sql_fszz = "select seldate,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-ym' and seldate>='"+vo.getStartMonth()+"' and seldate<='"+vo.getEndMonth()+"' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_qdje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate>='"+vo.getStartMonth()+"' and seldate<='"+vo.getEndMonth()+"' and cls='ht-ym' GROUP BY 1 order by seldate asc";
            }else{
                sql_qdje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate>='"+vo.getStartMonth()+"' and seldate<='"+vo.getEndMonth()+"' and cls='ht-ym' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_ckje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate>='"+vo.getStartMonth()+"' and seldate<='"+vo.getEndMonth()+"' and cls='ck-ym' GROUP BY 1 order by seldate asc";
            }else{
                sql_ckje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate>='"+vo.getStartMonth()+"' and seldate<='"+vo.getEndMonth()+"' and cls='ck-ym' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
        }else if(vo.getMode().equalsIgnoreCase("w")){
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_fszz = "select seldate,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-w' and seldate like '%"+vo.getWeekyear()+"%' GROUP BY 1 order by seldate asc";
            }else{
                sql_fszz = "select seldate,count(distinct customer_id) as customers from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and cls='ht-w' and seldate like '%"+vo.getWeekyear()+"%' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_qdje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate like '%"+vo.getWeekyear()+"%' and cls='ht-w' GROUP BY 1 order by seldate asc";
            }else{
                sql_qdje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate like '%"+vo.getWeekyear()+"%' and cls='ht-w' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
            if(vo.getPlatform().equalsIgnoreCase("all")){
                sql_ckje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate like '%"+vo.getWeekyear()+"%' and cls='ck-w' GROUP BY 1 order by seldate asc";
            }else{
                sql_ckje = "select seldate,ROUND(sum(money),0) as fee from dw.scb_fans_transfrom_part1 where type1='首次签单金额' and seldate like '%"+vo.getWeekyear()+"%' and cls='ck-w' and platform='"+vo.getPlatform()+"' GROUP BY 1 order by seldate asc";
            }
        }
        List<Map<String,Object>> fszz = sysYyZhouhuiFixedService.selectWeeksInfo(sql_fszz);
        List<Map<String,Object>> qdje = sysYyZhouhuiFixedService.selectWeeksInfo(sql_qdje);
        List<Map<String,Object>> ckje = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ckje);
        Map<String,Object> res = new HashMap<>();
        res.put("fszz",fszz);
        res.put("qdje",qdje);
        res.put("ckje",ckje);
        return AjaxResult.success(res);
    }

    @GetMapping("/listFszhPart2Summary")
    public AjaxResult listFszhPart2Summary(YxFansVo vo){
        String sql_summary = "select jd_w,sum(htmoney) as jdfee,sum(premoney) as yckfee,sum(fhmoney) as sjckfee from dw.scb_fans_transfrom_part2 where 1=1 ";
        String sql_detail = "select *,concat(substr(ht_code,3,4),'-',substr(ht_code,7,2),'-',substr(ht_code,9,2)) as qdrq from dw.scb_fans_transfrom_part2 where 1=1 ";
        String sql_sum = "select count(*) as totalPage from dw.scb_fans_transfrom_part2 where 1=1 ";
        sql_summary += " and jd_w like '%"+vo.getYear()+"%'";
        sql_detail += " and jd_w like '%"+vo.getYear()+"%'";
        if(!vo.getWeek().equalsIgnoreCase("all")){
            sql_summary += " and SUBSTRING_INDEX(jd_w,'_',-1)='"+vo.getWeek()+"'";
            sql_detail += " and SUBSTRING_INDEX(jd_w,'_',-1)='"+vo.getWeek()+"'";
            sql_sum += " and SUBSTRING_INDEX(jd_w,'_',-1)='"+vo.getWeek()+"'";
        }
        if(!vo.getOrdertype().equalsIgnoreCase("all")){
            sql_summary += " and type1='"+vo.getOrdertype()+"'";
            sql_detail += " and type1='"+vo.getOrdertype()+"'";
            sql_sum += " and type1='"+vo.getOrdertype()+"'";
        }
        if(!vo.getPlatform().equalsIgnoreCase("all")){
            sql_summary += " and platform='"+vo.getPlatform()+"'";
            sql_detail += " and platform='"+vo.getPlatform()+"'";
            sql_sum += " and platform='"+vo.getPlatform()+"'";
        }
        if(!vo.getHxxz().equalsIgnoreCase("all")){
            sql_summary += " and add_hg='"+vo.getHxxz()+"'";
            sql_detail += " and add_hg='"+vo.getHxxz()+"'";
            sql_sum += " and add_hg='"+vo.getHxxz()+"'";
        }
        sql_summary += " group by 1 order by jd_w asc";

        List<Map<String,Object>> countList = sysYyZhouhuiFixedService.selectWeeksInfo(sql_sum);
        int totalPage = 0;
        if(countList.size()>0){
            int total = Integer.parseInt(countList.get(0).get("totalPage").toString());
            int quotient  = total / vo.getPageSize();  // 向零取整的商
            int remainder = total % vo.getPageSize();
            if(remainder>0){
                totalPage = quotient+1;
            }else{
                totalPage = quotient;
            }
        }

        sql_detail += " order by jd_w desc,type1 asc,platform asc limit "+(vo.getPageNo()-1)*vo.getPageSize()+","+vo.getPageSize();
        List<Map<String,Object>> summary = sysYyZhouhuiFixedService.selectWeeksInfo(sql_summary);
        List<Map<String,Object>> detail = sysYyZhouhuiFixedService.selectWeeksInfo(sql_detail);
        Map<String,Object> res = new HashMap<>();
        res.put("summary",summary);
        res.put("detail",detail);
        res.put("totalPage",totalPage);
        res.put("pageNo",vo.getPageNo());
        res.put("pageSize",vo.getPageSize());
        return AjaxResult.success(res);
    }

    @GetMapping("/listYxfsData")
    public AjaxResult listYxfsData(YxFansVo vo){
        List<String> platforms = vo.getPlatforms();
        List<String> years = vo.getYears();
        String platStr = "";
        if(platforms != null && platforms.size() > 0){
            for(int i=0; i<platforms.size(); i++){
                if(i==0){
                    platStr += "'"+platforms.get(i)+"'";
                }else{
                    platStr += ",'"+platforms.get(i)+"'";
                }
            }
        }
        String yearStr = "";
        yearStr += "(";
        if(years != null && years.size() > 0){
            for(int i=0; i<years.size(); i++){
                if(i==0){
                    yearStr += " y_m like '%"+years.get(i)+"%'";
                }else{
                    yearStr += " or y_m like '%"+years.get(i)+"%'";
                }
            }
        }
        yearStr += ")";
        String sql = "select name,nick_name,platform,`date`,region,location,saleman_name,is_trans,consult from scb_validfans where platform in("+platStr+") and "+yearStr+" order by `date` desc";
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        return AjaxResult.success(res);
    }

    @GetMapping("/listYxfsLineSummary")
    public AjaxResult listYxfsLineSummary(YxFansVo vo){
        List<String> platforms = vo.getPlatforms();
        List<String> years = vo.getYears();
        String platStr = "";
        if(platforms != null && platforms.size() > 0){
            for(int i=0; i<platforms.size(); i++){
                if(i==0){
                    platStr += "'"+platforms.get(i)+"'";
                }else{
                    platStr += ",'"+platforms.get(i)+"'";
                }
            }
        }
        String yearStr = "";
        yearStr += "(";
        if(years != null && years.size() > 0){
            for(int i=0; i<years.size(); i++){
                if(i==0){
                    yearStr += " y_m like '%"+years.get(i)+"%'";
                }else{
                    yearStr += " or y_m like '%"+years.get(i)+"%'";
                }
            }
        }
        yearStr += ")";
        String sql = "";
        if(vo.getMode().equalsIgnoreCase("y")){
            sql = "select SUBSTR(y_m,1,4) as vdate,count(*) as nums from scb_validfans where platform in("+platStr+") and "+yearStr+" GROUP BY 1 order by vdate asc";
        }else if(vo.getMode().equalsIgnoreCase("m")){
            sql = "select y_m as vdate,count(*) as nums from scb_validfans where platform in("+platStr+") and "+yearStr+" GROUP BY 1 order by vdate asc";
        }else if(vo.getMode().equalsIgnoreCase("w")){
            sql = "SELECT concat(week_cn,'(',week_of_year,'周)') as `week`,concat(SUBSTR(y_m,1,4),'年第',week_of_year,'周') as vdate,count(*) as nums from scb_validfans where platform in("+platStr+") and "+yearStr+" GROUP BY 1,2 order by `week` asc";
        }
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        List<String> colors = new ArrayList<>();
        if(res != null && res.size() > 0){
            for(int i=0; i<res.size(); i++){
                Map<String,Object> map = res.get(i);
                BigDecimal hb = new BigDecimal("0");
                if(i>0){
                    Map<String,Object> map1 = res.get(i-1);
                    hb = new BigDecimal(map.get("nums").toString()).subtract(new BigDecimal(map1.get("nums").toString()));
                }
                map.put("hb", hb);
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
            }
        }
        Map<String, Object> result = new HashMap<>();
        result.put("list", res);
        result.put("colors", colors);
        return AjaxResult.success(result);
    }

    @GetMapping("/listAreaSummary")
    public AjaxResult listAreaSummary(YxFansVo vo){
        List<String> platforms = vo.getPlatforms();
        List<String> years = vo.getYears();
        String platStr = "";
        if(platforms != null && platforms.size() > 0){
            for(int i=0; i<platforms.size(); i++){
                if(i==0){
                    platStr += "'"+platforms.get(i)+"'";
                }else{
                    platStr += ",'"+platforms.get(i)+"'";
                }
            }
        }
        String yearStr = "";
        yearStr += "(";
        if(years != null && years.size() > 0){
            for(int i=0; i<years.size(); i++){
                if(i==0){
                    yearStr += " y_m like '%"+years.get(i)+"%'";
                }else{
                    yearStr += " or y_m like '%"+years.get(i)+"%'";
                }
            }
        }
        yearStr += ")";
        String sql ="select location,count(*) as nums from scb_validfans where platform in("+platStr+") and "+yearStr+" GROUP BY 1 order by nums desc";
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        List<String> colors = new ArrayList<>();
        BigDecimal total = new BigDecimal("0");
        if(res != null && res.size() > 0){
            for(Map<String,Object> map : res){
                total = total.add(new BigDecimal(map.get("nums").toString()));
            }
        }
        if (res != null && res.size() > 0){
            for(Map<String,Object> map : res){
                if(map.get("location")==null||"".equals(map.get("location").toString())){
                    map.put("location","Null");
                }
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
                BigDecimal rate = new BigDecimal(map.get("nums").toString()).divide(total, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                map.put("rate", rate);
            }
        }
        Map<String, Object> result = new HashMap<>();
        result.put("list", res);
        result.put("colors", colors);
        return AjaxResult.success(result);
    }
    @GetMapping("/listRegionSummary")
    public AjaxResult listRegionSummary(YxFansVo vo){
        List<String> platforms = vo.getPlatforms();
        List<String> years = vo.getYears();
        String platStr = "";
        if(platforms != null && platforms.size() > 0){
            for(int i=0; i<platforms.size(); i++){
                if(i==0){
                    platStr += "'"+platforms.get(i)+"'";
                }else{
                    platStr += ",'"+platforms.get(i)+"'";
                }
            }
        }
        String yearStr = "";
        yearStr += "(";
        if(years != null && years.size() > 0){
            for(int i=0; i<years.size(); i++){
                if(i==0){
                    yearStr += " y_m like '%"+years.get(i)+"%'";
                }else{
                    yearStr += " or y_m like '%"+years.get(i)+"%'";
                }
            }
        }
        yearStr += ")";
        String sql = "select region,count(*) as nums from scb_validfans where platform in("+platStr+") and "+yearStr+" GROUP BY 1";
        List<Map<String,Object>> res = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        List<String> colors = new ArrayList<>();
        BigDecimal total = new BigDecimal("0");
        if(res != null && res.size() > 0){
            for(Map<String,Object> map : res){
                total = total.add(new BigDecimal(map.get("nums").toString()));
            }
        }
        if (res != null && res.size() > 0){
            for(Map<String,Object> map : res){
                if(map.get("region")==null||"".equals(map.get("region").toString())){
                    map.put("region","Null");
                }
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
                BigDecimal rate = new BigDecimal(map.get("nums").toString()).divide(total, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                map.put("rate", rate);
            }
        }
        Map<String, Object> result = new HashMap<>();
        result.put("list", res);
        result.put("colors", colors);
        return AjaxResult.success(result);
    }

    @GetMapping("/listYxfsDicts")
    public AjaxResult listYxfsDicts(){
        String psql = "select distinct platform as `value`,platform as label from scb_validfans where platform is not null";
        List<Map<String,Object>> platforms = sysYyZhouhuiFixedService.selectWeeksInfo(psql);
        List<String> fplatform = new ArrayList<>();
        if(platforms.size()>0){
            for(Map<String,Object> map : platforms){
                if(map.get("value")!=null){
                    fplatform.add(map.get("value").toString());
                }
            }
        }
        String ysql = "select distinct SUBSTR(y_m,1,4) as `value`,SUBSTR(y_m,1,4) as label from scb_validfans where y_m is not null order by `value` asc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(ysql);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        List<String> fyears = new ArrayList<>();
        fyears.add(year);
        Map<String,Object> map = new HashMap<>();
        map.put("platforms",platforms);
        map.put("years",years);
        map.put("platformsInit",fplatform);
        map.put("year",fyears);
        map.put("mode","w");
        return AjaxResult.success(map);
    }

    @GetMapping("/listHjbbDicts")
    public AjaxResult listHjbbDicts(){
        String wksql = "select DISTINCT wek as `value`,wek as label from flower_market where wek is not null and wek!='' order by wek desc";
        List<Map<String,Object>> weeks = sysYyZhouhuiFixedService.selectWeeksInfo(wksql);
        String sourcesql = "select DISTINCT source as `value`,source as label from flower_market order by source desc";
        List<Map<String,Object>> sources = sysYyZhouhuiFixedService.selectSourcesInfo(sourcesql);
        List<Map<String,Object>> sourcesList = new ArrayList<>();
        Map<String,Object> sourceMap = new HashMap<>();
        sourceMap.put("value","all");
        sourceMap.put("label","(全部)");
        sourcesList.add(sourceMap);
        if(sources.size()>0){
            for(Map<String,Object> map : sources){
                sourcesList.add(map);
            }
        }
        String week = "";
        if(weeks.size()>0){
            week = weeks.get(0).get("value").toString();
        }
        Map<String,Object> res = new HashMap<>();
        res.put("weeks",weeks);
        res.put("week",week);
        res.put("sources",sourcesList);
        return AjaxResult.success(res);
    }

    @GetMapping("/listPlatFansSummary")
    public AjaxResult listPlatFansSummary(PlatformFansVo vo){
        List<String> years = vo.getYears();
        Collections.sort(years);
        List<Map<String,Object>> datas = new ArrayList<>();
        if(vo.getMode().equalsIgnoreCase("w")){
            for(String year : years){
                String sql = "select concat(SUBSTR(date,1,4),'年第',week_of_year,'周') as wkyear,paltform,fan_nums from scb_platfans WHERE paltform='"+vo.getPlatform()+"' and `date` like '%"+year+"%' order by week_of_year asc";
                List<Map<String,Object>> results = sysYyZhouhuiFixedService.selectPlatFansYears(sql);
                if(results.size()>0){
                    for(int i=0;i<results.size();i++){
                        if(i==0){
                            results.get(i).put("hb",0);
                        }else{
                            BigDecimal current = new BigDecimal(results.get(i).get("fan_nums").toString());
                            BigDecimal prev = new BigDecimal(results.get(i-1).get("fan_nums").toString());
                            results.get(i).put("hb",current.subtract(prev).setScale(0,BigDecimal.ROUND_HALF_UP));
                        }
                        results.get(i).put("fan_nums",new BigDecimal(results.get(i).get("fan_nums").toString()).setScale(0,BigDecimal.ROUND_HALF_UP));
                        datas.add(results.get(i));
                    }
                }
            }
        }else if(vo.getMode().equalsIgnoreCase("m")){
            for(String year : years){
                String sql = "select y_m as wkyear,paltform,max(fan_nums) as fan_nums from scb_platfans WHERE paltform='"+vo.getPlatform()+"' and `date` like '%"+year+"%' GROUP BY 1 order by y_m asc";
                List<Map<String,Object>> results = sysYyZhouhuiFixedService.selectPlatFansYears(sql);
                if(results.size()>0){
                    for(int i=0;i<results.size();i++){
                        if(i==0){
                            results.get(i).put("hb",0);
                        }else{
                            BigDecimal current = new BigDecimal(results.get(i).get("fan_nums").toString());
                            BigDecimal prev = new BigDecimal(results.get(i-1).get("fan_nums").toString());
                            results.get(i).put("hb",current.subtract(prev).setScale(0,BigDecimal.ROUND_HALF_UP));
                        }
                        results.get(i).put("fan_nums",new BigDecimal(results.get(i).get("fan_nums").toString()).setScale(0,BigDecimal.ROUND_HALF_UP));
                        datas.add(results.get(i));
                    }
                }
            }
        }else if(vo.getMode().equalsIgnoreCase("y")){
            for(String year : years){
                String sql = "select concat(SUBSTR(date,1,4)) as wkyear,paltform,max(fan_nums) as fan_nums from scb_platfans WHERE paltform='"+vo.getPlatform()+"' and `date` like '%"+year+"%' GROUP BY 1 order by wkyear asc";
                List<Map<String,Object>> results = sysYyZhouhuiFixedService.selectPlatFansYears(sql);
                if(results.size()>0){
                    for(int i=0;i<results.size();i++){
                        if(i==0){
                            results.get(i).put("hb",0);
                        }else{
                            BigDecimal current = new BigDecimal(results.get(i).get("fan_nums").toString());
                            BigDecimal prev = new BigDecimal(results.get(i-1).get("fan_nums").toString());
                            results.get(i).put("hb",current.subtract(prev).setScale(0,BigDecimal.ROUND_HALF_UP));
                        }
                        results.get(i).put("fan_nums",new BigDecimal(results.get(i).get("fan_nums").toString()).setScale(0,BigDecimal.ROUND_HALF_UP));
                        datas.add(results.get(i));
                    }
                }
            }
        }
        return AjaxResult.success(datas);
    }

    @GetMapping("/listPlatFansDict")
    public AjaxResult listPlatFansDict(){
        String sql = "select distinct SUBSTR(date,1,4) as `value`,concat(SUBSTR(date,1,4),'年') as label from scb_platfans order by `value` asc";
        List<Map<String,Object>> yearList = sysYyZhouhuiFixedService.selectPlatFansYears(sql);
        String pSql = "select distinct paltform as `value`,paltform as label from scb_platfans order by `value` asc";
        List<Map<String,Object>> platList = sysYyZhouhuiFixedService.selectPlatFansYears(pSql);
        Map<String,Object> res = new HashMap<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        List<String> years = new ArrayList<>();
        years.add(year);
        res.put("yearList",yearList);
        res.put("years",years);
        res.put("platList",platList);
        res.put("platform","抖音1");
        return AjaxResult.success(res);
    }

    @GetMapping("/listPlatFans")
    public AjaxResult listPlatFans(){

        String sqltype = "select distinct v2 as `name` from scb_xmt";
        List<Map<String,Object>> typesList = sysYyZhouhuiFixedService.selectPlatFansTypes(sqltype);
        List<Map<String,Object>> list = new ArrayList<>();
        if(typesList.size()>0){
            for(Map<String,Object> map : typesList){
                String name = (String) map.get("name");
                String sql = "";
                sql += "SELECT" +
                        "  sum( CASE WHEN v1 = '抖音1' THEN fan_nums ELSE 0 END ) AS dy1," +
                        "  sum( CASE WHEN v1 = '抖音2' THEN fan_nums ELSE 0 END ) AS dy2," +
                        "  sum( CASE WHEN v1 = '公众号' THEN fan_nums ELSE 0 END ) AS gzh," +
                        "  sum( CASE WHEN v1 = '活动' THEN fan_nums ELSE 0 END ) AS hd," +
                        "  sum( CASE WHEN v1 = '视频号' THEN fan_nums ELSE 0 END ) AS sph," +
                        "  sum( CASE WHEN v1 = '小红书' THEN fan_nums ELSE 0 END ) AS xhs," +
                        "  sum( CASE WHEN v1 = '转介绍' THEN fan_nums ELSE 0 END ) AS zjs " +
                        "FROM" +
                        "  scb_xmt " +
                        "WHERE" +
                        "  v2 = '"+name+"'";
                List<Map<String,Object>> datas = sysYyZhouhuiFixedService.selectPlatFansData(sql);
                if(datas.size()>0){
                    for(Map<String,Object> data : datas){
                        data.put("name",name);
                        list.add(data);
                    }
                }
            }
        }
        return AjaxResult.success(list);
    }

    @GetMapping("/listFlowerPriceDicts")
    public AjaxResult listFlowerPriceDicts(){
        Calendar calendar = Calendar.getInstance();
        // 获取上一年
        Calendar prevYearCalendar = (Calendar) calendar.clone();
        prevYearCalendar.add(Calendar.YEAR, -1);
        int prevYear = prevYearCalendar.get(Calendar.YEAR);
        // 获取下一年
        Calendar nextYearCalendar = (Calendar) calendar.clone();
        nextYearCalendar.add(Calendar.YEAR, 1);
        int nextYear = nextYearCalendar.get(Calendar.YEAR);
        String sql = "select distinct brand as `value`,brand as label from mark_flower_main";
        List<Map<String,Object>> brands = sysYyZhouhuiFixedService.selectRisePriceSummary(sql);
        Map<String,Object> res = new HashMap<>();
        res.put("startDate",prevYear+"-01-01");
        res.put("endDate",nextYear+"-12-31");
        res.put("brands",brands);
        return AjaxResult.success(res);
    }

    @GetMapping("/listBrandFlowerPrice")
    public AjaxResult listBrandFlowerPrice(CgDashVo vo){
        String sql = "";
        sql += "select ywek,wek,brand,lowprice,highprice,avgprice from dw.mark_flower_main where 1=1 ";
        if(vo.getStartDate()!=null&&vo.getEndDate()!=null){
            sql += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
        }
        sql += " and brand='"+vo.getBrand()+"' order by wek asc";
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectRisePriceSummary(sql);
        Random random = new Random();
        // 生成随机 RGB 值
        int red = random.nextInt(256);
        int green = random.nextInt(256);
        int blue = random.nextInt(256);
        String hexColor = String.format("#%02X%02X%02X", red, green, blue);
        Map<String,Object> res = new HashMap<>();
        res.put("list",list);
        res.put("color",hexColor);
        return AjaxResult.success(res);
    }

    @GetMapping("/listDownSummary")
    public AjaxResult listDownSummary(CgDashVo vo){
        String sql = "";
        sql += "select wek,source,cls,pz,lp,hb_lp,hp,hb_hp from flower_market where 1=1 ";
        sql += " and wek='"+vo.getWek()+"'";
        if(!vo.getSource().equalsIgnoreCase("all")){
            sql += " and source='"+vo.getSource()+"'";
        }
        sql += " and updown='跌' order by wek desc,source asc,cls asc,pz asc ";
        List<Map<String,Object>> riseList = sysYyZhouhuiFixedService.selectRisePriceSummary(sql);
        return AjaxResult.success(riseList);
    }

    @GetMapping("/listUnchangeSummary")
    public AjaxResult listUnchangeSummary(CgDashVo vo){
        String sql = "";
        sql += "select wek,source,cls,pz,lp,hb_lp,hp,hb_hp from flower_market where 1=1 ";
        sql += " and wek='"+vo.getWek()+"'";
        if(!vo.getSource().equalsIgnoreCase("all")){
            sql += " and source='"+vo.getSource()+"'";
        }
        sql += " and updown='平' order by wek desc,source asc,cls asc,pz asc ";
        List<Map<String,Object>> riseList = sysYyZhouhuiFixedService.selectRisePriceSummary(sql);
        return AjaxResult.success(riseList);
    }

    @GetMapping("/listRisePriceSummary")
    public AjaxResult listRisePriceSummary(CgDashVo vo){
        String sql = "";
        sql += "select wek,source,cls,pz,lp,hb_lp,hp,hb_hp from flower_market where 1=1 ";
        sql += " and wek='"+vo.getWek()+"'";
        if(!vo.getSource().equalsIgnoreCase("all")){
            sql += " and source='"+vo.getSource()+"'";
        }
        sql += " and updown='涨' order by wek desc,source asc,cls asc,pz asc ";
        List<Map<String,Object>> riseList = sysYyZhouhuiFixedService.selectRisePriceSummary(sql);
        return AjaxResult.success(riseList);
    }

    @GetMapping("/listCgMonthSummary")
    public AjaxResult listCgMonthSummary(CgDashVo vo){
        String sql = "";
        String sqlsum = "";
        sql += "select SUBSTR(vdate,1,7) as month,sum(qty) as qty,sum(orisum) as orisum from zhouhui_cg WHERE 1=1 ";
        sqlsum += "select sum(orisum) as orisum,sum(qty) as qty from zhouhui_cg WHERE 1=1 ";
        if(vo.getStartDate()!=null&&vo.getEndDate()!=null){
            sql += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
            sqlsum += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
        }
        if(vo.getCls()!=null&&!vo.getCls().equals("all")){
            sql += " and cls='"+vo.getCls()+"'";
            sqlsum += " and cls='"+vo.getCls()+"'";
        }
        if(vo.getIfWk()!=null&&!vo.getIfWk().equals("all")){
            sql += " and if_wk='"+vo.getIfWk()+"'";
            sqlsum += " and if_wk='"+vo.getIfWk()+"'";
        }
        if(vo.getProductName()!=null&&!vo.getProductName().replaceAll(" ","").equals("")){
            sql += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
            sqlsum += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
        }
        if(vo.getVendorName()!=null&&!vo.getVendorName().replaceAll(" ","").equals("")){
            sql += " and vendor_name='"+vo.getVendorName()+"'";
            sqlsum += " and vendor_name='"+vo.getVendorName()+"'";
        }
        sql += " GROUP BY 1 order by `month` asc";
        List<Map<String,Object>> totalSummary = sysYyZhouhuiFixedService.selectCgTotalSummary(sqlsum);
        BigDecimal totalMoney = new BigDecimal("0");
        BigDecimal totalQty = new BigDecimal("0");
        if(totalSummary!=null&&totalSummary.size()>0){
            if(totalSummary.get(0)!=null&&totalSummary.get(0).get("orisum")!=null){
                totalMoney = new BigDecimal(totalSummary.get(0).get("orisum").toString());
            }
            if(totalSummary.get(0)!=null&&totalSummary.get(0).get("qty")!=null){
                totalQty = new BigDecimal(totalSummary.get(0).get("qty").toString());
            }
        }
        List<Map<String,Object>> vendorSummary = sysYyZhouhuiFixedService.selectCgMonthSummary(sql);
        List<String> colors = new ArrayList<>();
        if(vendorSummary.size()>0){
            for(Map<String,Object> map:vendorSummary){
                BigDecimal orisum = new BigDecimal("0");
                if(map.get("orisum")!=null&&!map.get("orisum").equals("")){
                    orisum = new BigDecimal(map.get("orisum").toString());
                    map.put("orisum", orisum.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
                BigDecimal qty = new BigDecimal("0");
                if(map.get("qty")!=null&&!map.get("qty").equals("")){
                    qty = new BigDecimal(map.get("qty").toString());
                }
                BigDecimal mrate = orisum.divide(totalMoney, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                BigDecimal qrate = qty.divide(totalQty,2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                map.put("mrate", mrate);
                map.put("qrate", qrate);

                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("list",vendorSummary);
        res.put("colors",colors);
        return AjaxResult.success(res);
    }

    @GetMapping("/listBrandsSummary")
    public AjaxResult listBrandsSummary(CgDashVo vo){
        String sql = "";
        String sqlsum = "";
        sql += "select bigname,sum(orisum) as orisum,sum(qty) as qty from zhouhui_cg WHERE 1=1 ";
        sqlsum += "select sum(orisum) as orisum,sum(qty) as qty from zhouhui_cg WHERE 1=1 ";
        if(vo.getStartDate()!=null&&vo.getEndDate()!=null){
            sql += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
            sqlsum += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
        }
        if(vo.getCls()!=null&&!vo.getCls().equals("all")){
            sql += " and cls='"+vo.getCls()+"'";
            sqlsum += " and cls='"+vo.getCls()+"'";
        }
        if(vo.getIfWk()!=null&&!vo.getIfWk().equals("all")){
            sql += " and if_wk='"+vo.getIfWk()+"'";
            sqlsum += " and if_wk='"+vo.getIfWk()+"'";
        }
        if(vo.getProductName()!=null&&!vo.getProductName().replaceAll(" ","").equals("")){
            sql += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
            sqlsum += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
        }
        if(vo.getVendorName()!=null&&!vo.getVendorName().replaceAll(" ","").equals("")){
            sql += " and vendor_name='"+vo.getVendorName()+"'";
            sqlsum += " and vendor_name='"+vo.getVendorName()+"'";
        }
        sql += " group by 1 order by orisum asc";
        List<Map<String,Object>> totalSummary = sysYyZhouhuiFixedService.selectCgTotalSummary(sqlsum);
        BigDecimal totalMoney = new BigDecimal("0");
        BigDecimal totalQty = new BigDecimal("0");
        if(totalSummary!=null&&totalSummary.size()>0){
            if(totalSummary.get(0)!=null&&totalSummary.get(0).get("orisum")!=null){
                totalMoney = new BigDecimal(totalSummary.get(0).get("orisum").toString());
            }
            if(totalSummary.get(0)!=null&&totalSummary.get(0).get("qty")!=null){
                totalQty = new BigDecimal(totalSummary.get(0).get("qty").toString());
            }
        }
        List<Map<String,Object>> vendorSummary = sysYyZhouhuiFixedService.selectCgVendorSummary(sql);
        List<String> colors = new ArrayList<>();
        if(vendorSummary.size()>0){
            for(Map<String,Object> map:vendorSummary){
                BigDecimal orisum = new BigDecimal("0");
                if(map.get("orisum")!=null&&!map.get("orisum").equals("")){
                    orisum = new BigDecimal(map.get("orisum").toString());
                    map.put("orisum", orisum.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
                BigDecimal qty = new BigDecimal("0");
                if(map.get("qty")!=null&&!map.get("qty").equals("")){
                    qty = new BigDecimal(map.get("qty").toString());
                }
                BigDecimal mrate = orisum.divide(totalMoney, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                BigDecimal qrate = qty.divide(totalQty,2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                map.put("mrate", mrate);
                map.put("qrate", qrate);

                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("list",vendorSummary);
        res.put("colors",colors);
        return AjaxResult.success(res);
    }

    @GetMapping("/listVendorSummary")
    public AjaxResult listVendorSummary(CgDashVo vo){
        String sql = "";
        String sqlsum = "";
        sql += "select vendor_name,brand,sum(orisum) as orisum,sum(qty) as qty from zhouhui_cg WHERE 1=1 ";
        sqlsum += "select sum(orisum) as orisum,sum(qty) as qty from zhouhui_cg WHERE 1=1 ";
        if(vo.getStartDate()!=null&&vo.getEndDate()!=null){
            sql += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
            sqlsum += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
        }
        if(vo.getCls()!=null&&!vo.getCls().equals("all")){
            sql += " and cls='"+vo.getCls()+"'";
            sqlsum += " and cls='"+vo.getCls()+"'";
        }
        if(vo.getIfWk()!=null&&!vo.getIfWk().equals("all")){
            sql += " and if_wk='"+vo.getIfWk()+"'";
            sqlsum += " and if_wk='"+vo.getIfWk()+"'";
        }
        if(vo.getProductName()!=null&&!vo.getProductName().replaceAll(" ","").equals("")){
            sql += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
            sqlsum += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
        }
        sql += " group by 1,2 order by orisum asc";
        List<Map<String,Object>> totalSummary = sysYyZhouhuiFixedService.selectCgTotalSummary(sqlsum);
        BigDecimal totalMoney = new BigDecimal("0");
        BigDecimal totalQty = new BigDecimal("0");
        if(totalSummary!=null&&totalSummary.size()>0){
            if(totalSummary.get(0)!=null&&totalSummary.get(0).get("orisum")!=null){
                totalMoney = new BigDecimal(totalSummary.get(0).get("orisum").toString());
            }
            if(totalSummary.get(0)!=null&&totalSummary.get(0).get("qty")!=null){
                totalQty = new BigDecimal(totalSummary.get(0).get("qty").toString());
            }
        }
        List<Map<String,Object>> vendorSummary = sysYyZhouhuiFixedService.selectCgVendorSummary(sql);
        List<String> colors = new ArrayList<>();
        if(vendorSummary.size()>0){
            for(Map<String,Object> map:vendorSummary){
                BigDecimal orisum = new BigDecimal("0");
                if(map.get("orisum")!=null&&!map.get("orisum").equals("")){
                    orisum = new BigDecimal(map.get("orisum").toString());
                    map.put("orisum", orisum.setScale(2, BigDecimal.ROUND_HALF_UP));
                }
                BigDecimal qty = new BigDecimal("0");
                if(map.get("qty")!=null&&!map.get("qty").equals("")){
                    qty = new BigDecimal(map.get("qty").toString());
                }
                BigDecimal mrate = orisum.divide(totalMoney, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                BigDecimal qrate = qty.divide(totalQty,2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                map.put("mrate", mrate);
                map.put("qrate", qrate);

                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("list",vendorSummary);
        res.put("colors",colors);
        return AjaxResult.success(res);
    }

    @GetMapping("/listCgDetail")
    public AjaxResult listCgDetail(CgDashVo vo){
        String sql = "";
        sql += "select vendor_name,operator_name,bigname,xlname,product_name,vdate,djcode,orisum,qty,orisum*10000/qty as unit_price from zhouhui_cg where 1=1 ";
        if(vo.getStartDate()!=null&&vo.getEndDate()!=null){
            sql += " and vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
        }
        if(vo.getCls()!=null&&!vo.getCls().equals("all")){
            sql += " and cls='"+vo.getCls()+"'";
        }
        if(vo.getIfWk()!=null&&!vo.getIfWk().equals("all")){
            sql += " and if_wk='"+vo.getIfWk()+"'";
        }
        if(vo.getProductName()!=null&&!vo.getProductName().replaceAll(" ","").equals("")){
            sql += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
        }
        sql += " order by vdate desc, vendor_name asc,operator_name asc,bigname asc,xlname asc";
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectCgDetailList(sql);
        return AjaxResult.success(list);
    }

    @GetMapping("/listCgSummary")
    public AjaxResult listCgSummary(CgDashVo vo){
        String sql = "";
        sql += "SELECT '数量' AS typeName,  sum( CASE WHEN brand = '种子' THEN qty ELSE 0 END ) AS zz,  sum( CASE WHEN brand = '种苗' THEN qty ELSE 0 END ) AS zm,  sum( CASE WHEN brand = '种球' THEN qty ELSE 0 END ) AS zq,  sum( CASE WHEN brand = '其他' THEN qty ELSE 0 END ) AS qt FROM zhouhui_cg where ";
        String sql1 = "";
        sql1 += "SELECT '金额' AS typeName,  sum( CASE WHEN brand = '种子' THEN orisum ELSE 0 END ) AS zz,  sum( CASE WHEN brand = '种苗' THEN orisum ELSE 0 END ) AS zm,  sum( CASE WHEN brand = '种球' THEN orisum ELSE 0 END ) AS zq,  sum( CASE WHEN brand = '其他' THEN orisum ELSE 0 END ) AS qt FROM zhouhui_cg where ";
        if(vo.getStartDate()!=null&&vo.getEndDate()!=null){
            sql += "vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
            sql1 += "vdate >= '" + vo.getStartDate() + "' AND vdate <= '" + vo.getEndDate() + "'";
        }
        if(vo.getCls()!=null&&!vo.getCls().equals("all")){
            sql += " and cls='"+vo.getCls()+"'";
            sql1 += " and cls='"+vo.getCls()+"'";
        }
        if(vo.getIfWk()!=null&&!vo.getIfWk().equals("all")){
            sql += " and if_wk='"+vo.getIfWk()+"'";
            sql1 += " and if_wk='"+vo.getIfWk()+"'";
        }
        if(vo.getProductName()!=null&&!vo.getProductName().replaceAll(" ","").equals("")){
            sql += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
            sql1 += " and product_name like '%"+vo.getProductName().replaceAll(" ","")+"%'";
        }
        sql += " GROUP BY 1";
        sql1 += " GROUP BY 1";
        List<Map<String,Object>> res = new ArrayList<>();
        DecimalFormat decimalFormat = new DecimalFormat("#,###");
        DecimalFormat decimalFormat1 = new DecimalFormat("#,###.00");
        List<Map<String,Object>> moneyList = sysYyZhouhuiFixedService.selectCgMoneyList(sql1);
        if(moneyList!=null&&moneyList.size()>0){
            for(Map<String,Object> map:moneyList){
                if(new BigDecimal(map.get("zz").toString()).compareTo(new BigDecimal("0"))>0){
                    map.put("zz", decimalFormat1.format(new BigDecimal(map.get("zz").toString()).setScale(2, BigDecimal.ROUND_HALF_UP)));
                }else{
                    map.put("zz","0.00");
                }
                if(new BigDecimal(map.get("zq").toString()).compareTo(new BigDecimal("0"))>0){
                    map.put("zq", decimalFormat1.format(new BigDecimal(map.get("zq").toString()).setScale(2, BigDecimal.ROUND_HALF_UP)));
                }else{
                    map.put("zq","0.00");
                }
                if(new BigDecimal(map.get("zm").toString()).compareTo(new BigDecimal("0"))>0){
                    map.put("zm", decimalFormat1.format(new BigDecimal(map.get("zm").toString()).setScale(2,BigDecimal.ROUND_HALF_UP)));
                }else{
                    map.put("zm","0.00");
                }
                if(new BigDecimal(map.get("qt").toString()).compareTo(new BigDecimal("0"))>0){
                    map.put("qt", decimalFormat1.format(new BigDecimal(map.get("qt").toString()).setScale(2,BigDecimal.ROUND_HALF_UP)));
                }else{
                    map.put("qt","0.00");
                }
                res.add(map);
            }
        }
        List<Map<String,Object>> qtyList = sysYyZhouhuiFixedService.selectCgQtyList(sql);
        if(qtyList!=null&&qtyList.size()>0){
            for(Map<String,Object> map:qtyList){
                map.put("zz", decimalFormat.format(new BigDecimal(map.get("zz").toString()).setScale(0, BigDecimal.ROUND_HALF_UP)));
                map.put("zq", decimalFormat.format(new BigDecimal(map.get("zq").toString()).setScale(0, BigDecimal.ROUND_HALF_UP)));
                map.put("zm", decimalFormat.format(new BigDecimal(map.get("zm").toString()).setScale(0,BigDecimal.ROUND_HALF_UP)));
                map.put("qt", decimalFormat.format(new BigDecimal(map.get("qt").toString()).setScale(0,BigDecimal.ROUND_HALF_UP)));
                res.add(map);
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listCgDicts")
    public AjaxResult listCgDicts(){
        Map<String,Object> res = new HashMap<>();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        String startDate = year+"-01-01";
        String endDate = year+"-12-31";
        List<Map<String,Object>> cls = new ArrayList<>();
        Map<String,Object> clsMap = new HashMap<>();
        clsMap.put("value","all");
        clsMap.put("label","(全部)");
        cls.add(clsMap);
        List<Map<String,Object>> clsData = sysYyZhouhuiFixedService.selectCgCls(year);
        if(clsData!=null&&clsData.size()>0){
            for(Map<String,Object> map:clsData){
                cls.add(map);
            }
        }
        res.put("cls",cls);
        List<Map<String,Object>> ifwk = new ArrayList<>();
        Map<String,Object> ifwkMap = new HashMap<>();
        ifwkMap.put("value","all");
        ifwkMap.put("label","(全部)");
        ifwk.add(ifwkMap);
        List<Map<String,Object>> ifwkData = sysYyZhouhuiFixedService.selectCgIfwk(year);
        if(ifwkData!=null&&ifwkData.size()>0){
            for(Map<String,Object> map:ifwkData){
                ifwk.add(map);
            }
        }
        res.put("ifwk",ifwk);
        res.put("startDate",startDate);
        res.put("endDate",endDate);
        return AjaxResult.success(res);
    }

    @GetMapping("/listWeekCustomerDicts")
    public AjaxResult listWeekCustomerDicts(){
        List<Map<String,Object>> areas = new ArrayList<>();
        Map<String,Object> map = new HashMap<>();
        map.put("value","all");
        map.put("label","(全部)");
        areas.add(map);
        List<Map<String,Object>> areasInfo = sysYyZhouhuiFixedService.selectCustomerAreasInfo();
        if(areasInfo.size()>0){
            for(Map<String,Object> area : areasInfo){
                areas.add(area);
            }
        }
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectCustomerYearsInfo();
        String year = null;
        if(years.size()>0){
            year = years.get(0).get("value").toString();
        }
        Map<String,Object> res = new HashMap<>();
        res.put("areas",areas);
        res.put("years",years);
        res.put("year",year);
        return AjaxResult.success(res);
    }

    @GetMapping("/listFgMonthAreaSummary")
    public AjaxResult listFgMonthAreaSummary(WeeklyYsVo vo){
        List<Map<String,Object>> res = new ArrayList<>();
        List<Map<String,Object>> areas = new ArrayList<>();
        if(vo.getArea().equalsIgnoreCase("all")){
            areas = sysYyZhouhuiFixedService.selectFgMonthAreaSummary(vo.getAdtime());
        }else{
            areas = sysYyZhouhuiFixedService.selectFgMonthAreaSummaryByArea(vo.getAdtime(),vo.getArea());
        }

        int index = 0;
        if(areas.size()>0){
            for(Map<String,Object> area : areas){
                Map<String,Object> map = new HashMap<>();
                map.put("name",area.get("area"));
                List<Map<String,Object>> datas = sysYyZhouhuiFixedService.selectFgMonthData(vo.getAdtime(),area.get("area").toString());
                List<String> labels = new ArrayList<>();
                if(datas.size()>0){
                    for(Map<String,Object> data : datas){
                        labels.add(data.get("DATE").toString());
                    }
                }
                map.put("labels",labels);
                map.put("data",datas);
                map.put("chart","chart00"+index);
                index++;
                Random random = new Random();
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                map.put("color",hexColor);
                res.add(map);
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listFgMonthBigDeptAndArea")
    public AjaxResult listFgMonthBigDeptAndArea(WeeklyYsVo vo){
        List<Map<String,Object>> res = new ArrayList<>();
        List<Map<String,Object>> depts = sysYyZhouhuiFixedService.selectFgMonthDepts(vo.getAdtime());
        int index = 0;
        if(depts.size()>0){
            for(Map<String,Object> dept : depts){
                Map<String,Object> map = new HashMap<>();
                map.put("name",dept.get("area_1"));
                List<Map<String,Object>> datas = sysYyZhouhuiFixedService.selectFgMonthBigDeptAndArea(vo.getAdtime(),dept.get("area_1").toString());
                List<String> labels = new ArrayList<>();
                if(datas.size()>0){
                    for(Map<String,Object> data : datas){
                        labels.add(data.get("DATE").toString());
                    }
                }
                map.put("labels",labels);
                map.put("data",datas);
                map.put("chart","chart0"+index);
                index++;
                Random random = new Random();
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                map.put("color",hexColor);
                res.add(map);
            }
        }
        return AjaxResult.success(res);
    }

    @GetMapping("/listFgBigDeptAndArea")
    public AjaxResult listFgBigDeptAndArea(WeeklyYsVo vo){
        List<Map<String,Object>> bigDepts = sysYyZhouhuiFixedService.selectBigDeptsFg();
        List<String> bColors = new ArrayList<>();
        List<Map<String,Object>> rBigDepts = new ArrayList<>();
        if(bigDepts.size()>0){
            for(Map<String,Object> bigDept : bigDepts){
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                bColors.add(hexColor);
                rBigDepts.add(bigDept);
            }
        }
        List<Map<String,Object>> areas = new ArrayList<>();
        if(vo.getArea().equalsIgnoreCase("all")){
            areas = sysYyZhouhuiFixedService.selectFgAreaSummary();
        }else{
            areas = sysYyZhouhuiFixedService.selectFgAreaSummaryByArea(vo.getArea());
        }
        List<String> aColors = new ArrayList<>();
        List<Map<String,Object>> rAreas = new ArrayList<>();
        if(areas.size()>0){
            for(Map<String,Object> area : areas){
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                if(area.get("xd_lv")==null||area.get("xd_lv").toString().length()==0){
                    area.put("xd_lv","0");
                }
                if(area.get("fg_lv")==null||area.get("fg_lv").toString().length()==0){
                    area.put("fg_lv","0");
                }
                aColors.add(hexColor);
                rAreas.add(area);
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("areas",rAreas);
        res.put("bigDepts",rBigDepts);
        res.put("bColors",bColors);
        res.put("aColors",aColors);
        return AjaxResult.success(res);
    }

    @GetMapping("/listCustomerSummary")
    public AjaxResult listCustomerSummary(WeeklyYsVo vo){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
        String month = sdf.format(new Date());

        String sql = "select" +
                "            sum(case when vip_rank like '%V%' then 1 else 0 end) as hyzs," +
                "            sum(case when vip_rank like '%一般%' then 1 else 0 end) as ybkhzs," +
                "            sum(case when vip_rank like '%V+%' then 1 else 0 end) as vjzs," +
                "            sum(case when vip_rank like '%V0%' then 1 else 0 end) as vlzs," +
                "            sum(case when max_gxtime like '%"+month+"%' then 1 else 0 end) as bygjrs," +
                "            sum(case when adtime like '%"+month+"%' then 1 else 0 end) as dyxzrs," +
                "            sum(case when count_monthxd >=1 then 1 else 0 end) as dyxdkhs," +
                "            sum(case when count_monthxd =1 then 1 else 0 end) as dyxdyckhs," +
                "            sum(case when count_monthxd >1 then 1 else 0 end) as dyfgkhs " +
                "        from kh_mx where 1=1 ";
        if(!vo.getArea().equalsIgnoreCase("all")){
            if(vo.getArea().equalsIgnoreCase("销售部")){
                sql += " and kh_calss_1='销售部'";
            }else{
                sql += " and area='"+vo.getArea()+"'";
            }
        }
        Map<String,Object> res = sysYyZhouhuiFixedService.selectCustomerSummaryMap(sql);
        return AjaxResult.success(res);
    }

    @GetMapping("/listLastWeekCustomers")
    public AjaxResult listLastWeekCustomers(){
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        List<Map<String,Object>> lastWeekList = sysYyZhouhuiFixedService.selectLastWeekCustomers(year);
        if(lastWeekList.size()>0){
            for(Map<String,Object> lastWeek : lastWeekList){
                lastWeek.put("week",year+"-"+lastWeek.get("week"));
            }
        }
        return AjaxResult.success(lastWeekList);
    }

    @GetMapping("/listWeekIncreaseSummary")
    public AjaxResult listWeekIncreaseSummary(WeeklyYsVo vo){
        String sql = "SELECT" +
                "            b.week_of_year AS `week`," +
                "            sum( CASE WHEN a.vip_rank LIKE '%一般%' THEN 1 ELSE 0 END ) AS ybkhzs," +
                "            sum( CASE WHEN a.vip_rank LIKE '%V+%' THEN 1 ELSE 0 END ) AS vjzs," +
                "            sum( CASE WHEN a.vip_rank LIKE '%V0%' THEN 1 ELSE 0 END ) AS vlzs," +
                "            count(*) AS sum" +
                "        FROM " +
                "            dw.kh_mx a " +
                "            LEFT JOIN dm.dim_date b ON a.adtime = b.day_short ";
        sql += "WHERE a.adtime like '%"+vo.getAdtime()+"%'";
        if(!vo.getArea().equalsIgnoreCase("all")){
            if(vo.getArea().equalsIgnoreCase("销售部")){
                sql += " and a.kh_calss_1='销售部'";
            }else{
                sql += "and a.area = '"+vo.getArea()+"'";
            }
        }
        sql += " GROUP BY 1 ORDER BY `week` asc";
        List<Map<String,Object>> weekIncreaseList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql);
        return AjaxResult.success(weekIncreaseList);
    }

    @GetMapping("/listKhListSummary")
    public AjaxResult listKhListSummary(WeeklyYsVo vo){
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectCustomerYearsAscInfo();
        String sql1 = "";
        String sql01 = "";
        sql1 += "select kh_calss,";
        sql01 += "select '总和' as kh_calss,";
        for(int i = 0;i<years.size();i++){
            Map<String,Object> map = years.get(i);
            if(i==0){
                sql1 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql01 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }else{
                sql1 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql01 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }
        }
        sql1 += " from kh_mx ";
        sql01 += " from kh_mx";
        if(!vo.getArea().equalsIgnoreCase("all")){
            if(vo.getArea().equalsIgnoreCase("销售部")){
                sql1 += " where kh_calss_1='"+vo.getArea()+"'";
                sql01 += " where kh_calss_1='"+vo.getArea()+"'";
            }else{
                sql1 += " where area='"+vo.getArea()+"'";
                sql01 += " where area='"+vo.getArea()+"'";
            }
        }
        sql1 += " GROUP BY 1";
        List<Map<String,Object>> khList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql1);
        List<Map<String,Object>> khTotalList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql01);
        if(khTotalList.size()>0){
            for(Map<String,Object> kh : khTotalList){
                khList.add(kh);
            }
        }
        if(khList.size()>0) {
            for (int i = 0; i < khList.size(); i++) {
                Map<String, Object> map = khList.get(i);
                Integer sum = 0;
                for (int j = 0; j < years.size(); j++) {
                    if(years.get(j).get("value")!=null){
                        sum += Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                    }
                }
                map.put("sum", sum);
                for (int j = 0; j < years.size(); j++) {
                    if (j > 0) {
                        Integer pre = Integer.parseInt(map.get("y" + years.get(j - 1).get("value").toString()).toString());
                        Integer current = Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                        Integer diff = current - pre;
                        String rate = "";
                        if (diff > 0) {
                            if (pre == 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else if (pre > 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else if (diff < 0) {
                            Integer realdiff = pre - current;
                            if (current == 0) {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else {
                            rate = "0";
                        }
                        map.put("yrate" + years.get(j).get("value").toString(), rate);
                    }
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("khList",khList);
        return AjaxResult.success(res);
    }

    @GetMapping("/listAreaListSummary")
    public AjaxResult listAreaListSummary(WeeklyYsVo vo){
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectCustomerYearsAscInfo();
        String sql3 = "select area,";
        String sql03 = "select '总和' as area,";
        for(int i = 0;i<years.size();i++){
            Map<String,Object> map = years.get(i);
            if(i==0){
                sql3 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql03 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }else{
                sql3 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql03 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }
        }
        sql3 += " from kh_mx ";
        sql03 += " from kh_mx";
        if(!vo.getArea().equalsIgnoreCase("all")){
            if(vo.getArea().equalsIgnoreCase("销售部")){
                sql3 += " where kh_calss_1='"+vo.getArea()+"'";
                sql03 += " where kh_calss_1='"+vo.getArea()+"'";
            }else{
                sql3 += " where area='"+vo.getArea()+"'";
                sql03 += " where area='"+vo.getArea()+"'";
            }
        }
        sql3 += " GROUP BY 1";
        List<Map<String,Object>> areaList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql3);
        List<Map<String,Object>> areaTotalList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql03);
        if(areaTotalList.size()>0){
            for(Map<String,Object> area : areaTotalList){
                areaList.add(area);
            }
        }
        if(areaList.size()>0) {
            for (int i = 0; i < areaList.size(); i++) {
                Map<String, Object> map = areaList.get(i);
                Integer sum = 0;
                for (int j = 0; j < years.size(); j++) {
                    sum += Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                }
                map.put("sum", sum);
                for (int j = 0; j < years.size(); j++) {
                    if (j > 0) {
                        Integer pre = Integer.parseInt(map.get("y" + years.get(j - 1).get("value").toString()).toString());
                        Integer current = Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                        Integer diff = current - pre;
                        String rate = "";
                        if (diff > 0) {
                            if (pre == 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else if (pre > 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else if (diff < 0) {
                            Integer realdiff = pre - current;
                            if (current == 0) {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else {
                            rate = "0";
                        }
                        map.put("yrate" + years.get(j).get("value").toString(), rate);
                    }
                }
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("areaList",areaList);
        return AjaxResult.success(res);
    }


    @GetMapping("/listAreaSummaryData")
    public AjaxResult listAreaSummaryData(WeeklyYsVo vo){
        String sql4 = "select area,count(*) as amount from kh_mx ";
        if(!vo.getArea().equalsIgnoreCase("all")){
            if(vo.getArea().equalsIgnoreCase("销售部")){
                sql4 += " where kh_calss_1='"+vo.getArea()+"'";
            }else{
                sql4 += " where area='"+vo.getArea()+"'";
            }
        }
        sql4 += " GROUP BY 1 ";
        List<Map<String,Object>> areaSummaryList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql4);
        Map<String,Object> res = new HashMap<>();
        res.put("areaSummaryList",areaSummaryList);
        return AjaxResult.success(res);
    }


    @GetMapping("/listIncreaseSummary")
    public AjaxResult listIncreaseSummary(WeeklyYsVo vo){
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectCustomerYearsAscInfo();
        String sql1 = "";
        String sql01 = "";
        sql1 += "select kh_calss,";
        sql01 += "select '总和' as kh_calss,";
        for(int i = 0;i<years.size();i++){
            Map<String,Object> map = years.get(i);
            if(i==0){
                sql1 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql01 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }else{
                sql1 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql01 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }
        }
        sql1 += " from kh_mx ";
        sql01 += " from kh_mx";
        if(!vo.getArea().equalsIgnoreCase("all")){
            sql1 += " where area='"+vo.getArea()+"'";
            sql01 += " where area='"+vo.getArea()+"'";
        }
        sql1 += " GROUP BY 1";
        List<Map<String,Object>> khList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql1);
        List<Map<String,Object>> khTotalList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql01);
        if(khTotalList.size()>0){
            for(Map<String,Object> kh : khTotalList){
                khList.add(kh);
            }
        }
        if(khList.size()>0) {
            for (int i = 0; i < khList.size(); i++) {
                Map<String, Object> map = khList.get(i);
                Integer sum = 0;
                for (int j = 0; j < years.size(); j++) {
                    if(years.get(j).get("value")!=null){
                        sum += Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                    }
                }
                map.put("sum", sum);
                for (int j = 0; j < years.size(); j++) {
                    if (j > 0) {
                        Integer pre = Integer.parseInt(map.get("y" + years.get(j - 1).get("value").toString()).toString());
                        Integer current = Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                        Integer diff = current - pre;
                        String rate = "";
                        if (diff > 0) {
                            if (pre == 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else if (pre > 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else if (diff < 0) {
                            Integer realdiff = pre - current;
                            if (current == 0) {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else {
                            rate = "0";
                        }
                        map.put("yrate" + years.get(j).get("value").toString(), rate);
                    }
                }
            }
        }
        String sql2 = "select kh_calss_1 as name,count(*) as value from kh_mx ";
        if(!vo.getArea().equalsIgnoreCase("all")){
            sql2 += " where area='"+vo.getArea()+"'";
        }
        sql2 += " GROUP BY 1 ";
        List<Map<String,Object>> khSummaryList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql2);

        String sql3 = "select area,";
        String sql03 = "select '总和' as area,";
        for(int i = 0;i<years.size();i++){
            Map<String,Object> map = years.get(i);
            if(i==0){
                sql3 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql03 += "sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }else{
                sql3 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
                sql03 += ",sum(case when adtime like '%"+map.get("value")+"%' then 1 else 0 end ) as y"+map.get("value");
            }
        }
        sql3 += " from kh_mx ";
        sql03 += " from kh_mx";
        if(!vo.getArea().equalsIgnoreCase("all")){
            sql3 += " where area='"+vo.getArea()+"'";
        }
        sql3 += " GROUP BY 1";
        List<Map<String,Object>> areaList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql3);
        List<Map<String,Object>> areaTotalList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql03);
        if(areaTotalList.size()>0){
            for(Map<String,Object> area : areaTotalList){
                areaList.add(area);
            }
        }
        if(areaList.size()>0) {
            for (int i = 0; i < areaList.size(); i++) {
                Map<String, Object> map = areaList.get(i);
                Integer sum = 0;
                for (int j = 0; j < years.size(); j++) {
                    sum += Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                }
                map.put("sum", sum);
                for (int j = 0; j < years.size(); j++) {
                    if (j > 0) {
                        Integer pre = Integer.parseInt(map.get("y" + years.get(j - 1).get("value").toString()).toString());
                        Integer current = Integer.parseInt(map.get("y" + years.get(j).get("value").toString()).toString());
                        Integer diff = current - pre;
                        String rate = "";
                        if (diff > 0) {
                            if (pre == 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else if (pre > 0) {
                                rate = "" + new BigDecimal(diff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else if (diff < 0) {
                            Integer realdiff = pre - current;
                            if (current == 0) {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal("1"), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            } else {
                                rate = "-"+new BigDecimal(realdiff).divide(new BigDecimal(pre), 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                            }
                        } else {
                            rate = "0";
                        }
                        map.put("yrate" + years.get(j).get("value").toString(), rate);
                    }
                }
            }
        }
        String sql4 = "select area,count(*) as amount from kh_mx ";
        if(!vo.getArea().equalsIgnoreCase("all")){
            sql4 += " where area='"+vo.getArea()+"'";
        }
        sql4 += " GROUP BY 1 ";
        List<Map<String,Object>> areaSummaryList = sysYyZhouhuiFixedService.selectCustomerIncreaseSummary(sql4);
        Map<String,Object> res = new HashMap<>();
        res.put("khList",khList);
        res.put("areaList",areaList);
        res.put("areaSummaryList",areaSummaryList);
        res.put("khSummaryList",khSummaryList);
        return AjaxResult.success(res);
    }

    /**
     * 查询SysYyZhouhuiFixed列表
     */
    @GetMapping("/list")
    public TableDataInfo list(SysYyZhouhuiFixed sysYyZhouhuiFixed) {
        startPage();
        List<SysYyZhouhuiFixed> list = sysYyZhouhuiFixedService.selectSysYyZhouhuiFixedList(sysYyZhouhuiFixed);
        return getDataTable(list);
    }

    /**
     * 导出SysYyZhouhuiFixed列表
     */
    @Log(title = "SysYyZhouhuiFixed", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysYyZhouhuiFixed sysYyZhouhuiFixed) {
        List<SysYyZhouhuiFixed> list = sysYyZhouhuiFixedService.selectSysYyZhouhuiFixedList(sysYyZhouhuiFixed);
        ExcelUtil<SysYyZhouhuiFixed> util = new ExcelUtil<SysYyZhouhuiFixed>(SysYyZhouhuiFixed.class);
        util.exportExcel(response, list, "SysYyZhouhuiFixed数据");
    }

    /**
     * 获取SysYyZhouhuiFixed详细信息
     */
    @GetMapping(value = "/{yYear}")
    public AjaxResult getInfo(@PathVariable("yYear") String yYear) {
        return success(sysYyZhouhuiFixedService.selectSysYyZhouhuiFixedByYYear(yYear));
    }

    /**
     * 新增SysYyZhouhuiFixed
     */
    @Log(title = "SysYyZhouhuiFixed", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysYyZhouhuiFixed sysYyZhouhuiFixed) {
        return toAjax(sysYyZhouhuiFixedService.insertSysYyZhouhuiFixed(sysYyZhouhuiFixed));
    }

    /**
     * 修改SysYyZhouhuiFixed
     */
    @Log(title = "SysYyZhouhuiFixed", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysYyZhouhuiFixed sysYyZhouhuiFixed) {
        return toAjax(sysYyZhouhuiFixedService.updateSysYyZhouhuiFixed(sysYyZhouhuiFixed));
    }

    /**
     * 删除SysYyZhouhuiFixed
     */
    @Log(title = "SysYyZhouhuiFixed", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yYears}")
    public AjaxResult remove(@PathVariable String[] yYears) {
        return toAjax(sysYyZhouhuiFixedService.deleteSysYyZhouhuiFixedByYYears(yYears));
    }

    @GetMapping("/listYjSummary")
    public AjaxResult listYjSummary() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        LocalDate date = LocalDate.now();
        LocalDate lastWeekDate = date.minusWeeks(0);
        // 获取上周的周数
        int week = lastWeekDate.get(WeekFields.ISO.weekOfWeekBasedYear());
        int month = LocalDate.now().getMonthValue();
        String yearstr = year+"年";
        String monthstr = yearstr+month+"月份";
        String weekstr = yearstr+"第"+week+"周";
        Map<String,Object> res = new HashMap<>();
        res.put("year",yearstr);
        res.put("month",monthstr);
        res.put("week",weekstr);
        String sql = "SELECT" +
                "  y_year," +
                "  ROUND(sum( CASE WHEN statu = 'w接单' THEN qty ELSE 0 END ),2) AS zjdqty," +
                "  ROUND(sum( CASE WHEN statu = 'w接单' THEN money ELSE 0 END ),2) AS zjdmoney," +
                "  ROUND(sum( CASE WHEN statu = 'w出库' THEN qty ELSE 0 END ),2) AS zckqty," +
                "  ROUND(sum( CASE WHEN statu = 'w出库' THEN money ELSE 0 END ),2) AS zckdmoney," +
                "  ROUND(sum( CASE WHEN statu = 'm度接单' THEN qty ELSE 0 END ),2) AS yjdqty," +
                "  ROUND(sum( CASE WHEN statu = 'm度接单' THEN money ELSE 0 END ),2) AS yjdmoney," +
                "  ROUND(sum( CASE WHEN statu = 'm出库' THEN qty ELSE 0 END ),2) AS yckqty," +
                "  ROUND(sum( CASE WHEN statu = 'm出库' THEN money ELSE 0 END ),2) AS yckmoney," +
                "  ROUND(sum( CASE WHEN statu = 'yy度接单' THEN qty ELSE 0 END ),2) AS njdqty," +
                "  ROUND(sum( CASE WHEN statu = 'yy度接单' THEN money ELSE 0 END ),2) AS njdmoney," +
                "  ROUND(sum( CASE WHEN statu = 'y出库' THEN qty ELSE 0 END ),2) AS nckqty," +
                "  ROUND(sum( CASE WHEN statu = 'y出库' THEN money ELSE 0 END ),2) AS nckmoney," +
                "  ROUND(sum( CASE WHEN statu = 'y度接单' THEN qty ELSE 0 END ),2) AS yjjdqty," +
                "  ROUND(sum( CASE WHEN statu = 'y度接单' THEN money ELSE 0 END ),2) AS yjjdmoney," +
                "  ROUND(sum( CASE WHEN statu = '代出库' THEN qty ELSE 0 END ),2) AS yjdckqty," +
                "  ROUND(sum( CASE WHEN statu = '代出库' THEN money ELSE 0 END ),2) AS yjdckmoney" +
                " FROM" +
                " yy_zhouhui_fixed " +
                " WHERE" +
                " dpt1 = '电商' " +
                " AND y_year = '"+year+"'" +
                " GROUP BY 1";
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectWeeksInfo(sql);
        res.put("list",list);
        return AjaxResult.success(res);
    }

    @GetMapping("/listProductQuery")
    public AjaxResult listProductQuery(XmtVo vo) {
        String sql_zcm = "";
        String sql_qt = "";
        String sql_ymd = "";
        String sql_yjg = "";
        if(vo.getMode().equalsIgnoreCase("y")){
            sql_zcm = "select bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and brand='自产苗' GROUP BY 1 ORDER BY money asc";
            sql_qt = "select bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and brand='其他' GROUP BY 1 ORDER BY money asc";
            sql_ymd = "select concat(bigname,'-',xlname) as bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and brand='洋牡丹' GROUP BY 1 ORDER BY money asc";
            sql_yjg = "select concat(bigname,'-',xlname) as bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and brand='洋桔梗' GROUP BY 1 ORDER BY money asc";
        }else if(vo.getMode().equalsIgnoreCase("m")){
            sql_zcm = "select bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' and brand='自产苗' GROUP BY 1 ORDER BY money asc";
            sql_qt = "select bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' and brand='其他' GROUP BY 1 ORDER BY money asc";
            sql_ymd = "select concat(bigname,'-',xlname) as bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' and brand='洋牡丹' GROUP BY 1 ORDER BY money asc";
            sql_yjg = "select concat(bigname,'-',xlname) as bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' and brand='洋桔梗' GROUP BY 1 ORDER BY money asc";
        }else if(vo.getMode().equalsIgnoreCase("w")){
            sql_zcm = "select bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' and brand='自产苗' GROUP BY 1 ORDER BY money asc";
            sql_qt = "select bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' and brand='其他' GROUP BY 1 ORDER BY money asc";
            sql_ymd = "select concat(bigname,'-',xlname) as bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' and brand='洋牡丹' GROUP BY 1 ORDER BY money asc";
            sql_yjg = "select concat(bigname,'-',xlname) as bigname,ROUND(IFNULL(sum(money),0)/10000,2) as money,sum(qty) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' and brand='洋桔梗' GROUP BY 1 ORDER BY money asc";
        }
        List<Map<String,Object>> zcm = sysYyZhouhuiFixedService.selectWeeksInfo(sql_zcm);
        List<Map<String,Object>> qt = sysYyZhouhuiFixedService.selectWeeksInfo(sql_qt);
        List<Map<String,Object>> ymd = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ymd);
        List<Map<String,Object>> yjg = sysYyZhouhuiFixedService.selectWeeksInfo(sql_yjg);
        Map<String,Object> res = new HashMap<>();
        res.put("zcm",zcm);
        res.put("qt",qt);
        res.put("ymd",ymd);
        res.put("yjg",yjg);
        return AjaxResult.success(res);
    }

    @GetMapping("/listStaffData")
    public AjaxResult listStaffData(XmtVo vo) {
        String sql_jd = "";
        String sql_ck = "";
        if(vo.getMode().equalsIgnoreCase("y")){
            sql_jd = "select brand,salename,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and salename='"+vo.getStaff()+"' GROUP BY 1,2 order by money desc";
            sql_ck = "select brand,salename,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ck' and vochdate like '%"+vo.getYear()+"%' and salename='"+vo.getStaff()+"' GROUP BY 1,2 order by money desc";
        }else if(vo.getMode().equalsIgnoreCase("m")){
            sql_jd = "select brand,salename,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' and salename='"+vo.getStaff()+"' GROUP BY 1,2 order by money desc";
            sql_ck = "select brand,salename,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ck' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' and salename='"+vo.getStaff()+"' GROUP BY 1,2 order by money desc";
        }else if(vo.getMode().equalsIgnoreCase("w")){
            sql_jd = "select brand,salename,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' and salename='"+vo.getStaff()+"' GROUP BY 1,2 order by money desc";
            sql_ck = "select brand,salename,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ck' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' and salename='"+vo.getStaff()+"' GROUP BY 1,2 order by money desc";
        }
        Map<String,Object> res = new HashMap<>();
        List<Map<String,Object>> jdc = sysYyZhouhuiFixedService.selectWeeksInfo(sql_jd);
        List<Map<String,Object>> ckc = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);

        List<Map<String,Object>> jdt = new ArrayList<>();
        jdt.addAll(jdc);
        List<Map<String,Object>> ckt = new ArrayList<>();
        ckt.addAll(ckc);

        Map<String,Object> jda = new HashMap<>();
        jda.put("brand","合计");
        BigDecimal moneyjd = new BigDecimal(0);
        BigDecimal qtyjd = new BigDecimal(0);
        if(jdc.size()>0){
            for(Map<String,Object> jd:jdc){
                moneyjd = moneyjd.add(new BigDecimal(jd.get("money").toString()));
                qtyjd = qtyjd.add(new BigDecimal(jd.get("qty").toString()));
            }
        }
        jda.put("money",moneyjd.setScale(2,BigDecimal.ROUND_HALF_UP));
        jda.put("qty",qtyjd.setScale(2,BigDecimal.ROUND_HALF_UP));
        jdt.add(jda);

        Map<String,Object> cka = new HashMap<>();
        cka.put("brand","合计");
        cka.put("salename","-");
        BigDecimal moneyck = new BigDecimal(0);
        BigDecimal qtyck = new BigDecimal(0);
        if(ckc.size()>0){
            for(Map<String,Object> ck:ckc){
                moneyck = moneyck.add(new BigDecimal(ck.get("money").toString()));
                qtyck = qtyck.add(new BigDecimal(ck.get("qty").toString()));
            }
        }
        cka.put("money",moneyck.setScale(2,BigDecimal.ROUND_HALF_UP));
        cka.put("qty",qtyck.setScale(2,BigDecimal.ROUND_HALF_UP));
        ckt.add(cka);

        if(jdc.size()>0) {
            for (Map<String, Object> jd : jdc) {
                BigDecimal mrate = new BigDecimal(jd.get("money").toString()).divide(moneyjd,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                BigDecimal qrate = new BigDecimal(jd.get("qty").toString()).divide(qtyjd,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                jd.put("mrate",mrate);
                jd.put("qrate",qrate);
            }
        }

        if(ckc.size()>0) {
            for (Map<String, Object> ck : ckc) {
                BigDecimal mrate = new BigDecimal(ck.get("money").toString()).divide(moneyck,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                BigDecimal qrate = new BigDecimal(ck.get("qty").toString()).divide(qtyck,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                ck.put("mrate",mrate);
                ck.put("qrate",qrate);
            }
        }
        res.put("jdc",jdc);
        res.put("ckc",ckc);
        res.put("jdt",jdt);
        res.put("ckt",ckt);
        return AjaxResult.success(res);
    }

    @GetMapping("/listBrandData")
    public AjaxResult listBrandData(XmtVo vo) {
        String sql_jd = "";
        String sql_ck = "";
        if(vo.getMode().equalsIgnoreCase("y")){
            sql_jd = "select brand,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' GROUP BY 1 order by money desc";
            sql_ck = "select brand,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ck' and vochdate like '%"+vo.getYear()+"%' GROUP BY 1 order by money desc";
        }else if(vo.getMode().equalsIgnoreCase("m")){
            sql_jd = "select brand,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' GROUP BY 1 order by money desc";
            sql_ck = "select brand,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ck' and vochdate like '%"+vo.getYear()+"%' and ym='"+vo.getYear()+"-"+vo.getMonth()+"' GROUP BY 1 order by money desc";
        }else if(vo.getMode().equalsIgnoreCase("w")){
            sql_jd = "select brand,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ht' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' GROUP BY 1 order by money desc";
            sql_ck = "select brand,ROUND(IFNULL(sum(money),0)/10000,2) as money,ROUND(IFNULL(sum(qty),0)/10000,2) as qty from yy_zhouhui where bigdpt = '电商' and cls='ck' and vochdate like '%"+vo.getYear()+"%' and wk_year like '%"+vo.getWeek()+"%' GROUP BY 1 order by money desc";
        }

        Map<String,Object> res = new HashMap<>();
        List<Map<String,Object>> jdc = sysYyZhouhuiFixedService.selectWeeksInfo(sql_jd);
        List<Map<String,Object>> ckc = sysYyZhouhuiFixedService.selectWeeksInfo(sql_ck);

        List<Map<String,Object>> jdt = new ArrayList<>();
        jdt.addAll(jdc);
        List<Map<String,Object>> ckt = new ArrayList<>();
        ckt.addAll(ckc);

        Map<String,Object> jda = new HashMap<>();
        jda.put("brand","合计");
        BigDecimal moneyjd = new BigDecimal(0);
        BigDecimal qtyjd = new BigDecimal(0);
        if(jdc.size()>0){
            for(Map<String,Object> jd:jdc){
                moneyjd = moneyjd.add(new BigDecimal(jd.get("money").toString()));
                qtyjd = qtyjd.add(new BigDecimal(jd.get("qty").toString()));
            }
        }
        jda.put("money",moneyjd.setScale(2,BigDecimal.ROUND_HALF_UP));
        jda.put("qty",qtyjd.setScale(2,BigDecimal.ROUND_HALF_UP));
        jdt.add(jda);

        Map<String,Object> cka = new HashMap<>();
        cka.put("brand","合计");
        BigDecimal moneyck = new BigDecimal(0);
        BigDecimal qtyck = new BigDecimal(0);
        if(ckc.size()>0){
            for(Map<String,Object> ck:ckc){
                moneyck = moneyck.add(new BigDecimal(ck.get("money").toString()));
                qtyck = qtyck.add(new BigDecimal(ck.get("qty").toString()));
            }
        }
        cka.put("money",moneyck.setScale(2,BigDecimal.ROUND_HALF_UP));
        cka.put("qty",qtyck.setScale(2,BigDecimal.ROUND_HALF_UP));
        ckt.add(cka);

        if(jdc.size()>0) {
            for (Map<String, Object> jd : jdc) {
                BigDecimal mrate = new BigDecimal(jd.get("money").toString()).divide(moneyjd,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                BigDecimal qrate = new BigDecimal(jd.get("qty").toString()).divide(qtyjd,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                jd.put("mrate",mrate);
                jd.put("qrate",qrate);
            }
        }

        if(ckc.size()>0) {
            for (Map<String, Object> ck : ckc) {
                BigDecimal mrate = new BigDecimal(ck.get("money").toString()).divide(moneyck,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                BigDecimal qrate = new BigDecimal(ck.get("qty").toString()).divide(qtyck,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                ck.put("mrate",mrate);
                ck.put("qrate",qrate);
            }
        }

        res.put("jdc",jdc);
        res.put("ckc",ckc);
        res.put("jdt",jdt);
        res.put("ckt",ckt);
        return AjaxResult.success(res);
    }

    @GetMapping("/listBrandParam")
    public AjaxResult listBrandParam() {
        String sql_year = "select distinct substr(ym,1,4) as `value`,concat(substr(ym,1,4),'年') as label from yy_zhouhui order by `value` desc";
        List<Map<String,Object>> years = sysYyZhouhuiFixedService.selectWeeksInfo(sql_year);
        SimpleDateFormat yearsdf = new SimpleDateFormat("yyyy");
        String year = yearsdf.format(new Date());
        Map<String,Object> res = new HashMap<>();
        SimpleDateFormat monthsdf = new SimpleDateFormat("MM");
        String month = monthsdf.format(new Date());
        LocalDate date = LocalDate.now();
        LocalDate lastWeekDate = date.minusWeeks(0);
        // 获取上周的周数
        String week = lastWeekDate.get(WeekFields.ISO.weekOfWeekBasedYear())+"wk";
        String sql_month = "select distinct substr(ym,6) as `value`,concat(substr(ym,6),'月') as label from yy_zhouhui order by `value` desc";
        List<Map<String,Object>> months = sysYyZhouhuiFixedService.selectWeeksInfo(sql_month);
        String sql_week = "select distinct substr(wk_year,23) as `value`,concat('第',replace(substr(wk_year,23),'wk','周')) as label,CAST(replace(substr(wk_year,23),'wk','') AS SIGNED)as `week` from yy_zhouhui order by `week` desc";
        List<Map<String,Object>> weeks = sysYyZhouhuiFixedService.selectWeeksInfo(sql_week);
        res.put("year",year);
        res.put("years",years);
        res.put("month",month);
        res.put("months",months);
        res.put("week",week);
        res.put("weeks",weeks);
        return AjaxResult.success(res);
    }

    @GetMapping("/listDictData")
    public AjaxResult listDictData() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        String year = sdf.format(new Date());
        List<Map<String,Object>> statusList = sysYyZhouhuiFixedService.selectZhStatu(year);
        Map<String,Object> statuMap = new HashMap<>();
        statuMap.put("value", "all");
        statuMap.put("label", "(全部)");
        List<Map<String,Object>> statuRes = new ArrayList<>();
        statuRes.add(statuMap);
        if(statusList!=null&&statusList.size()>0){
            for(Map<String,Object> map:statusList){
                Map<String,Object> subMap = new HashMap<>();
                if(map.get("statu")!=null){
                    if(map.get("statu").toString().equals("w接单")){
                        subMap.put("value", "w接单");
                        subMap.put("label", "周接单");
                    }else if(map.get("statu").toString().equals("w出库")){
                        subMap.put("value", "w出库");
                        subMap.put("label", "周出库");
                    }else if(map.get("statu").toString().equals("m度接单")){
                        subMap.put("value", "m度接单");
                        subMap.put("label", "月出单");
                    }else if(map.get("statu").toString().equals("m出库")){
                        subMap.put("value", "m出库");
                        subMap.put("label", "月出库");
                    }else if(map.get("statu").toString().equals("yy度接单")){
                        subMap.put("value", "yy度接单");
                        subMap.put("label", "年度接单");
                    }else if(map.get("statu").toString().equals("y出库")){
                        subMap.put("value", "y出库");
                        subMap.put("label", "年度出库");
                    }else if(map.get("statu").toString().equals("y度接单")){
                        subMap.put("value", "y度接单");
                        subMap.put("label", "预计出库");
                    }else if(map.get("statu").toString().equals("代出库")){
                        subMap.put("value", "代出库");
                        subMap.put("label", "预计待出库");
                    }
                }
                statuRes.add(subMap);
            }
        }
        List<Map<String,Object>> bigDeptsList = sysYyZhouhuiFixedService.selectBigDepts(year);
        List<Map<String,Object>> bigDeptsRes = new ArrayList<>();
        Map<String,Object> bigDeptMap = new HashMap<>();
        bigDeptMap.put("value", "all");
        bigDeptMap.put("label", "(全部)");
        bigDeptsRes.add(bigDeptMap);
        Map<String,Object> bigDeptMap1 = new HashMap<>();
        bigDeptMap1.put("value", "0000");
        bigDeptMap1.put("label", "代理和销售部");
        bigDeptsRes.add(bigDeptMap1);
        if(bigDeptsList!=null&&bigDeptsList.size()>0){
            for(Map<String,Object> map:bigDeptsList){
                bigDeptsRes.add(map);
            }
        }

        List<Map<String,Object>> subDeptsList = sysYyZhouhuiFixedService.selectSubDepts(year);
        List<Map<String,Object>> subDeptsRes = new ArrayList<>();
        Map<String,Object> subDeptMap = new HashMap<>();
        subDeptMap.put("value", "all");
        subDeptMap.put("label", "(全部)");
        subDeptsRes.add(subDeptMap);
        if(subDeptsList!=null&&subDeptsList.size()>0){
            for(Map<String,Object> map:subDeptsList){
                subDeptsRes.add(map);
            }
        }

        List<Map<String,Object>> brandsList = sysYyZhouhuiFixedService.selectBrands(year);
        List<Map<String,Object>> brandsRes = new ArrayList<>();
        Map<String,Object> brandMap = new HashMap<>();
        brandMap.put("value", "all");
        brandMap.put("label", "(全部)");
        brandsRes.add(brandMap);
        if(brandsList!=null&&brandsList.size()>0){
            for(Map<String,Object> map:brandsList){
                brandsRes.add(map);
            }
        }
        List<Map<String,Object>> yearsRes = new ArrayList<>();
        List<Map<String,Object>> yearsList = sysYyZhouhuiFixedService.selectYears(year);
        if(yearsList!=null&&yearsList.size()>0){
            for(Map<String,Object> map:yearsList){
                yearsRes.add(map);
            }
        }
        Map<String,Object> result = new HashMap<>();
        result.put("statusList", statuRes);
        result.put("bigDeptsList", bigDeptsRes);
        result.put("subDeptsList", subDeptsRes);
        result.put("brandsList", brandsRes);
        result.put("yearsList", yearsRes);
        return AjaxResult.success(result);
    }

    @GetMapping("/listWeekDetailSummary")
    public AjaxResult listWeekDetailSummary(WeeklyYsVo vo) {
        SysYyZhouhui zhouhui = new SysYyZhouhui();
        if(vo.getStatus() != null){
            if(!vo.getBigDepts().toString().equalsIgnoreCase("all")){
                zhouhui.setBigdpt(vo.getBigDepts());
            }
        }
        if(vo.getSubDepts()!=null){
            if(!vo.getSubDepts().toString().equalsIgnoreCase("all")){
                zhouhui.setDpt(vo.getSubDepts());
            }
        }
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
        SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
        LocalDate date1 = LocalDate.now();
        DayOfWeek dayOfWeek = date1.getDayOfWeek();
        String wkYear = "";
        if(dayOfWeek == DayOfWeek.MONDAY||dayOfWeek == DayOfWeek.TUESDAY){
            // 获取上周同一日期
            LocalDate lastWeekDate = date1.minusWeeks(1);
            // 获取上周的周数
            int lastWeekOfYear = lastWeekDate.get(WeekFields.ISO.weekOfWeekBasedYear());
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.YEAR, Integer.parseInt(sdf.format(date)));
            cal.set(Calendar.WEEK_OF_YEAR, lastWeekOfYear);
            cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            String monday = sdf1.format(cal.getTime());
            // 获取周一和周日的日期
            Calendar endOfWeek = Calendar.getInstance();
            endOfWeek.setTime(cal.getTime());
            endOfWeek.add(Calendar.DAY_OF_WEEK, 6);
            String sunday = sdf1.format(endOfWeek.getTime());
            wkYear = monday+"至"+sunday+"_"+lastWeekOfYear+"wk";
            zhouhui.setWkYear(wkYear);
        }else{
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(date);
            // 获取一年中的第几周，具体取决于 Calendar 类的设置
            int weekOfYear = calendar.get(Calendar.WEEK_OF_YEAR);
            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.YEAR, Integer.parseInt(sdf.format(date)));
            cal.set(Calendar.WEEK_OF_YEAR, weekOfYear);
            cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            String monday = sdf1.format(cal.getTime());
            // 获取周一和周日的日期
            Calendar endOfWeek = Calendar.getInstance();
            endOfWeek.setTime(cal.getTime());
            endOfWeek.add(Calendar.DAY_OF_WEEK, 6);
            String sunday = sdf1.format(endOfWeek.getTime());
            wkYear = monday+"至"+sunday+"_"+weekOfYear+"wk";
            zhouhui.setWkYear(wkYear);
        }
        logger.info("-------status-------"+vo.getStatus());
        logger.info("-------wkYear-------"+wkYear);
        logger.info("-------bigdept-------"+vo.getBigDepts());
        logger.info("-------subdept-------"+vo.getSubDepts());
        String sql_brand = "select distinct brand FROM yy_zhouhui WHERE cls = 'ht' and wk_year='"+wkYear+"'";
        String sql_detail = "SELECT wk_year, brand, bigname, sum( qty ) AS qty, ROUND(IFNULL(sum( money ),0)/10000,2) AS money FROM yy_zhouhui WHERE cls = 'ht' and wk_year = '"+wkYear+"'";
        String sql_detail_subsum = "SELECT wk_year, brand,'合计' as bigname,sum( qty ) AS qty, ROUND(IFNULL(sum( money ),0)/10000,2) AS money FROM yy_zhouhui WHERE cls = 'ht' and wk_year = '"+wkYear+"'";
        String sql_sum = "SELECT wk_year,'合计' as brand,'-' as bigname,sum( qty ) AS qty, ROUND(IFNULL(sum( money ),0)/10000,2) AS money FROM yy_zhouhui WHERE cls = 'ht' and wk_year = '"+wkYear+"'";
        if(vo.getStatus() != null){
            if(!vo.getBigDepts().toString().equalsIgnoreCase("all")){
                if(vo.getBigDepts().toString().equalsIgnoreCase("0000")){
                    sql_brand += " and bigdpt in ('代理','销售部') ";
                    sql_detail += " and bigdpt in ('代理','销售部') ";
                    sql_detail_subsum += " and bigdpt in ('代理','销售部') ";
                    sql_sum += " and bigdpt in ('代理','销售部') ";
                }else{
                    sql_brand += " and bigdpt='"+vo.getBigDepts()+"'";
                    sql_detail += " and bigdpt='"+vo.getBigDepts()+"'";
                    sql_detail_subsum += " and bigdpt='"+vo.getBigDepts()+"'";
                    sql_sum += " and bigdpt='"+vo.getBigDepts()+"'";
                }
            }
        }
        if(vo.getSubDepts()!=null){
            if(!vo.getSubDepts().toString().equalsIgnoreCase("all")){
                sql_brand += " and dpt='"+vo.getSubDepts()+"'";
                sql_detail += " and dpt='"+vo.getSubDepts()+"'";
                sql_detail_subsum += " and dpt='"+vo.getSubDepts()+"'";
                sql_sum += " and dpt='"+vo.getSubDepts()+"'";
            }
        }
        if(vo.getBrands()!=null){
            if(!vo.getBrands().toString().equalsIgnoreCase("all")){
                sql_brand += " and brand='"+vo.getBrands()+"'";
                sql_sum += " and brand='"+vo.getBrands()+"'";
            }
        }
        List<Map<String,Object>> brands = ysYyZhouhuiService.selectWeekDetailInfo(sql_brand);
        List<Map<String,Object>> reslist = new ArrayList<>();
        if(brands.size()>0){
            for (Map<String,Object> map : brands) {
                if(map.get("brand")!=null){
                    String detail_sql = sql_detail+" and brand='"+map.get("brand")+"' GROUP BY 1, 2, 3 order by brand asc";
                    String detail_subsum_sql = sql_detail_subsum+" and brand='"+map.get("brand")+"' GROUP BY 1, 2";
                    List<Map<String,Object>> infos = ysYyZhouhuiService.selectWeekDetailInfo(detail_sql);
                    reslist.addAll(infos);
                    List<Map<String,Object>> subSumInfos = ysYyZhouhuiService.selectWeekDetailInfo(detail_subsum_sql);
                    reslist.addAll(subSumInfos);
                }
            }
        }
        List<Map<String,Object>> sumInfos = ysYyZhouhuiService.selectWeekDetailInfo(sql_sum);
        reslist.addAll(sumInfos);
        List<Map<String,Object>> list = ysYyZhouhuiService.selectWeekDetailSummary(zhouhui);
        Map<String,Object> result = new HashMap<>();
//        result.put("list", list);
        result.put("list", reslist);
        List<Map<String,Object>> brandSummary = ysYyZhouhuiService.selectWeekBrandSummary(zhouhui);
        result.put("brand", brandSummary);
        List<Map<String,Object>> totalSummary = ysYyZhouhuiService.selectWeekTotalSummary(zhouhui);
        result.put("total", totalSummary);
        List<String> labels = new ArrayList<>();
        if(brandSummary.size()>0){
            for(Map<String,Object> map : brandSummary){
                if(map.get("brand")!=null){
                    labels.add(map.get("brand").toString());
                }
            }
        }
        result.put("labels", labels);
        return AjaxResult.success(result);
    }

    @GetMapping("/listBugetSummary")
    public AjaxResult listBugetSummary(WeeklyYsVo vo) {
        List<Map<String,Object>> list = budgetYouyongService.selectBugetSummary(vo.getYears());
        List<String> labels = new ArrayList<>();
        List<Map<String,Object>> qtyList = new ArrayList<>();
        List<Map<String,Object>> feeList = new ArrayList<>();
        List<String> colors = new ArrayList<>();
        if(list!=null&&list.size()>0){
            for(Map<String,Object> map:list){
                labels.add(map.get("month").toString()+"月份");
                Map<String,Object> qtyMap = new HashMap<>();
                qtyMap.put("year", map.get("year").toString());
                qtyMap.put("month", map.get("month").toString());
                qtyMap.put("achive_qty", map.get("achive_qty").toString());
                qtyMap.put("bud_qty", map.get("bud_qty").toString());
                if(map.get("qty_rate")!=null){
                    qtyMap.put("qty_rate", map.get("qty_rate").toString());
                }else{
                    qtyMap.put("qty_rate", 0);
                }
                qtyList.add(qtyMap);
                Map<String,Object> feeMap = new HashMap<>();
                feeMap.put("year", map.get("year").toString());
                feeMap.put("month", map.get("month").toString());
                feeMap.put("achive_money", map.get("achive_money").toString());
                feeMap.put("bud_money", map.get("bud_money").toString());
                if(map.get("money_rate")!=null){
                    feeMap.put("money_rate", map.get("money_rate").toString());
                }else{
                    feeMap.put("money_rate", 0);
                }
                feeList.add(feeMap);
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
            }
        }
        Map<String,Object> res = new HashMap<>();
        res.put("labels", labels);
        res.put("qtyList", qtyList);
        res.put("feeList", feeList);
        res.put("colors", colors);
        return AjaxResult.success(res);
    }

    @GetMapping("/listDetailSummary")
    public AjaxResult listDetailSummary(WeeklyYsVo vo) {
        SysYyZhouhuiFixed fixed = new SysYyZhouhuiFixed();
        if(vo.getStatus() != null){
            if(!vo.getStatus().toString().equalsIgnoreCase("all")){
                fixed.setStatu(vo.getStatus());
            }
        }
        if(vo.getStatus() != null){
            if(!vo.getBigDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt1(vo.getBigDepts());
            }
        }
        if(vo.getSubDepts()!=null){
            if(!vo.getSubDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt2(vo.getSubDepts());
            }
        }
        if(vo.getBrands()!=null){
            if(!vo.getBrands().toString().equalsIgnoreCase("all")){
                fixed.setDdClass(vo.getBrands());
            }
        }
        fixed.setyYear(vo.getYears());
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectDetailSummaryData(fixed);
        return AjaxResult.success(list);
    }

    @GetMapping("/listBrandSummary")
    public AjaxResult listBrandSummary(WeeklyYsVo vo) {
        SysYyZhouhuiFixed fixed = new SysYyZhouhuiFixed();
        if(vo.getStatus() != null){
            if(!vo.getStatus().toString().equalsIgnoreCase("all")){
                fixed.setStatu(vo.getStatus());
            }
        }
        if(vo.getStatus() != null){
            if(!vo.getBigDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt1(vo.getBigDepts());
            }
        }
        if(vo.getSubDepts()!=null){
            if(!vo.getSubDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt2(vo.getSubDepts());
            }
        }
        if(vo.getBrands()!=null){
            if(!vo.getBrands().toString().equalsIgnoreCase("all")){
                fixed.setDdClass(vo.getBrands());
            }
        }
        fixed.setyYear(vo.getYears());
        List<Map<String,Object>> totalList = sysYyZhouhuiFixedService.selectBrandsTotalData(fixed);
        BigDecimal totalSum = new BigDecimal(0);
        if(totalList!=null&&totalList.size()>0){
            if(totalList.get(0)!=null){
                if(totalList.get(0).get("money")!=null){
                    totalSum = new BigDecimal(Double.parseDouble(totalList.get(0).get("money").toString()));
                }
            }
        }
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectBrandSummaryData(fixed);
        List<String> colors = new ArrayList<>();
        List<String> labels = new ArrayList<>();
        if(list.size()>0){
            for(Map<String,Object> map:list){
                BigDecimal money = new BigDecimal(map.get("money").toString());
                labels.add(map.get("brand").toString());
                BigDecimal rate = new BigDecimal(0);
                if(totalSum.compareTo(new BigDecimal(0))>0){
                    rate = money.divide(totalSum,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                }
                map.put("rate", rate);
                Random random = new Random();
                // 生成随机 RGB 值
                int red = random.nextInt(256);
                int green = random.nextInt(256);
                int blue = random.nextInt(256);
                String hexColor = String.format("#%02X%02X%02X", red, green, blue);
                colors.add(hexColor);
            }
        }
        Map<String,Object> result = new HashMap<>();
        result.put("colors", colors);
        result.put("labels", labels);
        result.put("list", list);
        return AjaxResult.success(result);
    }

    @GetMapping("/listSubDeptSummary")
    public AjaxResult listSubDeptSummary(WeeklyYsVo vo) {
        SysYyZhouhuiFixed fixed = new SysYyZhouhuiFixed();
        if(vo.getStatus() != null){
            if(!vo.getStatus().toString().equalsIgnoreCase("all")){
                fixed.setStatu(vo.getStatus());
            }
        }
        if(vo.getStatus() != null){
            if(!vo.getBigDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt1(vo.getBigDepts());
            }
        }
        if(vo.getSubDepts()!=null){
            if(!vo.getSubDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt2(vo.getSubDepts());
            }
        }
        if(vo.getBrands()!=null){
            if(!vo.getBrands().toString().equalsIgnoreCase("all")){
                fixed.setDdClass(vo.getBrands());
            }
        }
        fixed.setyYear(vo.getYears());
        List<Map<String,Object>> totalList = sysYyZhouhuiFixedService.selectSubDeptTotalData(fixed);
        BigDecimal totalSum = new BigDecimal(0);
        if(totalList!=null&&totalList.size()>0){
            if(totalList.get(0)!=null){
                if(totalList.get(0).get("money")!=null&&!totalList.get(0).get("money").toString().equalsIgnoreCase("")){
                    totalSum = new BigDecimal(Double.parseDouble(totalList.get(0).get("money").toString()));
                }
            }
        }
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectSubDeptSummaryData(fixed);
        List<String> colors = new ArrayList<>();
        List<BigDecimal> datas = new ArrayList<>();
        List<String> labels = new ArrayList<>();
        List<String> dpt1 = new ArrayList<>();
        List<String> rates = new ArrayList<>();
        if(list.size()>0){
            for(Map<String,Object> map:list){
                BigDecimal money = new BigDecimal(map.get("money").toString());
                datas.add(money);
                labels.add(map.get("dpt2").toString());
                dpt1.add(map.get("dpt1").toString());
                BigDecimal rate = new BigDecimal(0);
                if(totalSum.compareTo(new BigDecimal(0))>0){
                    rate = money.divide(totalSum,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"));
                }
                map.put("rate", rate);
                rates.add(rate+"%");
                if(fixed.getDpt1().equalsIgnoreCase("0000")){
                    if(map.get("dpt1").toString().equalsIgnoreCase("代理")){
                        colors.add("#f06cdc");
                    }else{
                        colors.add("#b286bf");
                    }
                }else {
                    colors.add("#eea854");
                }
            }
        }
        Map<String,Object> result = new HashMap<>();
        result.put("colors", colors);
        result.put("datas", datas);
        result.put("labels", labels);
        result.put("list", list);
        return AjaxResult.success(result);
    }

    @GetMapping("/listSummaryData")
    public AjaxResult listSummaryData(WeeklyYsVo vo) {
        SysYyZhouhuiFixed fixed = new SysYyZhouhuiFixed();
//        if(vo.getStatus() != null){
//            if(!vo.getStatus().toString().equalsIgnoreCase("all")){
//                fixed.setStatu(vo.getStatus());
//            }
//        }
        if(vo.getStatus() != null){
            if(!vo.getBigDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt1(vo.getBigDepts());
            }
        }
        if(vo.getSubDepts()!=null){
            if(!vo.getSubDepts().toString().equalsIgnoreCase("all")){
                fixed.setDpt2(vo.getSubDepts());
            }
        }
        if(vo.getBrands()!=null){
            if(!vo.getBrands().toString().equalsIgnoreCase("all")){
                fixed.setDdClass(vo.getBrands());
            }
        }
        fixed.setyYear(vo.getYears());
        List<Map<String,Object>> list = sysYyZhouhuiFixedService.selectSummaryData(fixed);
        Map<String,Object> result = new HashMap<>();
        if(list!=null&&list.size()>0){
            result = list.get(0);
        }
        return AjaxResult.success(result);
    }
}
